コード例 #1
0
ファイル: Database.py プロジェクト: toxictigga/wdmcgen2
def __loadDB():
    global __dbThread
    __dbThread = Thread.Create(__loadDBInThread)

    # Give the database thread time to start accepting queries
    while not __alive:
        time.sleep(0.1)

    # If the database needs to be created, load the defaults file & call the create function
    if __shouldCreate:
        try:
            path = "%s/Contents/DefaultDatabase.sql" % Plugin.__bundlePath
            if os.path.exists(path):
                f = open(path, "r")
                string = f.read()
                f.close()
                Exec(string)
                PMS.Log("(Framework) Loaded the default database file")
                Commit()
            Plugin.__callNamed("CreateDatabase")
            PMS.Log("(Framework) Created database tables")
        except:
            PMS.Log("(Framework) Error creating database tables", False)
        finally:
            Commit()
コード例 #2
0
ファイル: Plugin.py プロジェクト: torarnv/Framework.bundle
def __startCacheManager(firstRun=False):
    Thread.CreateTimer(HTTP.__autoUpdateCacheTime,
                       __triggerAutoHTTPCacheUpdate)
    if "UpdateCache" in __pluginModule.__dict__:
        if firstRun:
            Thread.Create(__triggerCacheUpdate)
        else:
            Thread.CreateTimer((__cacheUpdateInterval / 2) +
                               random.randrange(__cacheUpdateInterval),
                               __triggerCacheUpdate)
        PMS.Log("(Framework) Cache manager started")
コード例 #3
0
ファイル: Decorators.py プロジェクト: toxictigga/wdmcgen2
 def __call__(self, f):
   self.name = f.__name__
   if progressive_load.loaders.has_key(self.name):
     self = progressive_load.loaders[self.name]
   else:
     PMS.Log("(Framework) Started a new progressive loader named '%s'" % self.name)
     self.__function = f
     self.last_fetch_time = Datetime.Now()
     progressive_load.loaders[self.name] = self
     Thread.Create(progressive_load.__runLoader, self)
   i = 0
   while i < 10 and len(self.container) == 0:
     Thread.Sleep(0.1)
   return self.getContainer()
コード例 #4
0
def PreCache(url,
             values=None,
             headers={},
             cacheTime=None,
             autoUpdate=False,
             encoding=None,
             errors=None):
    Thread.Create(Request,
                  url=url,
                  values=values,
                  headers=headers,
                  cacheTime=cacheTime,
                  autoUpdate=autoUpdate,
                  encoding=encoding,
                  errors=errors)
コード例 #5
0
    def __call__(self):
        PMS.Log("(Framework) Starting a parallel task set named '%s'" %
                self.tasksetname)

        # Try & fetch the task set
        try:
            taskset = parallel.tasksets[self.tasksetname]
        except:
            PMS.Log(
                "(Framework) ERROR: Unable to start the task set named '%s'" %
                self.tasksetname)
            return

        if len(taskset) == 0:
            PMS.Log(
                "(Framework) ERROR: The task set named '%s' contains no tasks"
                % self.tasksetname)
            return

        # Start tasks, making sure we don't go over the maximum limit
        lockname = "Framework.Parallel." + self.tasksetname
        taskindex = 0
        while taskindex < len(taskset):
            Thread.Lock(lockname, addToLog=False)
            if self.threadcount < parallel.maxThreads:
                Thread.Create(self.__runtask__, taskset[taskindex])
                taskindex += 1
            Thread.Unlock(lockname, addToLog=False)
            Thread.Sleep(0.05)

        # Wait for all threads to terminate
        while True:
            Thread.Lock(lockname, addToLog=False)
            if self.threadcount > 0:
                Thread.Unlock(lockname, addToLog=False)
                Thread.Sleep(0.05)
            else:
                Thread.Unlock(lockname, addToLog=False)
                break

        # Remove the task set
        PMS.Log("(Framework) Parallel task set named '%s' has finished." %
                self.tasksetname)
コード例 #6
0
 def __call__(self):
     Thread.Create(self.f)