/usr/share/pyshared/socketpool/backend_gevent.py is in python-socketpool 0.5.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | # -*- coding: utf-8 -
#
# This file is part of socketpool.
# See the NOTICE for more information.
import gevent
from gevent import select
from gevent import socket
from gevent import queue
from socketpool.pool import ConnectionPool
try:
from gevent import lock
except ImportError:
#gevent < 1.0b2
from gevent import coros as lock
sleep = gevent.sleep
Semaphore = lock.BoundedSemaphore
Socket = socket.socket
Select = select.select
class PriorityQueue(queue.PriorityQueue):
def __next__(self):
try:
result = self.get(block=False)
except queue.Empty:
raise StopIteration
return result
next = __next__
class ConnectionReaper(gevent.Greenlet):
running = False
def __init__(self, pool, delay=150):
self.pool = pool
self.delay = delay
gevent.Greenlet.__init__(self)
def _run(self):
self.running = True
while True:
gevent.sleep(self.delay)
self.pool.murder_connections()
def ensure_started(self):
if not self.running or self.ready():
self.start()
|