!C99Shell v. 2.0 [PHP 7 Update] [25.02.2019]!

Software: Apache/2.2.16 (Debian). PHP/5.3.3-7+squeeze19 

uname -a: Linux mail.tri-specialutilitydistrict.com 2.6.32-5-amd64 #1 SMP Tue May 13 16:34:35 UTC
2014 x86_64
 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/usr/share/pyshared/deskbar/core/   drwxr-xr-x
Free 129.99 GB of 142.11 GB (91.47%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     ThreadPool.py (2.66 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
import Queue
import threading

class ThreadPool(object):
    """
    Implements a thread pool
    
    This class is used to query each module
    """

    max = 20
    started = False # Whether the pool has been started
    name = None
    workers = 0 # Number of worker threads (they pickup functions from the queue)

    def __init__(self, maxthreads=20, name=None):
        """Create a new threadpool.

        @param maxthreads: maximum number of threads in the pool
        """
        self.q = Queue.Queue(0)
        self.max = maxthreads
        self.name = name
        
        self.threads = []
        self.working = []
        
    def start(self):
        """Start the threadpool.
        """
        self.started = True
        # Start some threads.
        self.adjustPoolsize()

    def startAWorker(self):
        self.workers = self.workers + 1
        name = "PoolThread-%s" % (self.name or self.workers)
        try:
            firstJob = self.q.get(0)
        except Queue.Empty:
            return
        newThread = threading.Thread(target=self._worker, name=name, args=(firstJob,))
        self.threads.append(newThread)
        newThread.start()

    def _startSomeWorkers(self):
        while (
            self.workers < self.max and # Don't create too many
            self.q.qsize() > 0
            ):
            self.startAWorker()

    def callInThread(self, func, *args, **kw):
        o = (func, args, kw)
        self.q.put(o)
        if self.started:
            self._startSomeWorkers()

    def _worker(self, o):
        ct = threading.currentThread()
        
        while True:
            if o is not None:
                self.working.append(ct)
                function, args, kwargs = o
                
                function(*args, **kwargs)
                
                self.working.remove(ct)
                del o, function, args, kwargs
            try:
                o = self.q.get(False) # Get new element from queue
            except Queue.Empty:
                break
        
        self.threads.remove(ct)
        self.workers = self.workers - 1

    def stop(self):
        """Shutdown the threads in the threadpool."""
        self.q = Queue.Queue(0)

    def adjustPoolsize(self, maxthreads=None):
        if maxthreads is None:
            maxthreads = self.max

        self.max = maxthreads
        if not self.started:
            return

        # Start some threads if there is a need.
        self._startSomeWorkers()

    def stats(self):
        print "Queue size: %i" % self.q.qsize()
        #print "Working: "
        #print self.working
        print "Workers: %i" % self.workers
        #print "Threads: "
        #print self.threads

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.0085 ]--