Handle requests from the proxies in a particular process/thread
'''
util.debug('starting server thread to service %r',
- threading.current_thread().get_name())
+ threading.current_thread().name)
recv = conn.recv
send = conn.send
except EOFError:
util.debug('got EOF -- exiting thread serving %r',
- threading.current_thread().get_name())
+ threading.current_thread().name)
sys.exit(0)
except Exception:
send(('#UNSERIALIZABLE', repr(msg)))
except Exception as e:
util.info('exception in thread serving %r',
- threading.current_thread().get_name())
+ threading.current_thread().name)
util.info(' ... message was %r', msg)
util.info(' ... exception was %r', e)
conn.close()
'''
Spawn a new thread to serve this connection
'''
- threading.current_thread().set_name(name)
+ threading.current_thread().name = name
c.send(('#RETURN', None))
self.serve_client(c)
def _connect(self):
util.debug('making connection to manager')
name = current_process().get_name()
- if threading.current_thread().get_name() != 'MainThread':
- name += '|' + threading.current_thread().get_name()
+ if threading.current_thread().name != 'MainThread':
+ name += '|' + threading.current_thread().name
conn = self._Client(self._token.address, authkey=self._authkey)
dispatch(conn, None, 'accept_connection', (name,))
self._tls.connection = conn
conn = self._tls.connection
except AttributeError:
util.debug('thread %r does not own a connection',
- threading.current_thread().get_name())
+ threading.current_thread().name)
self._connect()
conn = self._tls.connection
# the process owns no more references to objects for this manager
if not idset and hasattr(tls, 'connection'):
util.debug('thread %r has no more proxies so closing conn',
- threading.current_thread().get_name())
+ threading.current_thread().name)
tls.connection.close()
del tls.connection
#delay = random.random() * 2
delay = 0
if support.verbose:
- print('task', self.get_name(), 'will run for', delay, 'sec')
+ print('task', self.name, 'will run for', delay, 'sec')
sema.acquire()
mutex.acquire()
running += 1
mutex.release()
time.sleep(delay)
if support.verbose:
- print('task', self.get_name(), 'done')
+ print('task', self.name, 'done')
mutex.acquire()
running -= 1
if support.verbose:
- print(self.get_name(), 'is finished.', running, 'tasks are running')
+ print(self.name, 'is finished.', running, 'tasks are running')
mutex.release()
sema.release()