3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-01-11 20:52:42 +01:00

relay: be more verbose in 'grabbing spawnlocks' messages

This commit is contained in:
James Lu 2017-06-29 23:10:53 -07:00 committed by James Lu
parent 60788e4ba5
commit f2b644e2bb

View File

@ -3,6 +3,7 @@ import time
import threading import threading
import string import string
from collections import defaultdict from collections import defaultdict
import inspect
from pylinkirc import utils, world, conf, structures from pylinkirc import utils, world, conf, structures
from pylinkirc.log import log from pylinkirc.log import log
@ -244,7 +245,8 @@ def get_remote_sid(irc, remoteirc, spawn_if_missing=True):
"""Gets the remote server SID representing remoteirc on irc, spawning """Gets the remote server SID representing remoteirc on irc, spawning
it if it doesn't exist (and spawn_if_missing is enabled).""" it if it doesn't exist (and spawn_if_missing is enabled)."""
log.debug('(%s) Grabbing spawnlocks_servers[%s]', irc.name, irc.name) log.debug('(%s) Grabbing spawnlocks_servers[%s] from thread %r in function %r', irc.name, irc.name,
threading.current_thread().name, inspect.currentframe().f_code.co_name)
if spawnlocks_servers[irc.name].acquire(timeout=TCONDITION_TIMEOUT): if spawnlocks_servers[irc.name].acquire(timeout=TCONDITION_TIMEOUT):
try: try:
sid = relayservers[irc.name][remoteirc.name] sid = relayservers[irc.name][remoteirc.name]
@ -355,7 +357,8 @@ def get_remote_user(irc, remoteirc, user, spawn_if_missing=True, times_tagged=0)
if sbot: if sbot:
return sbot.uids.get(remoteirc.name) return sbot.uids.get(remoteirc.name)
log.debug('(%s) Grabbing spawnlocks[%s]', irc.name, irc.name) log.debug('(%s) Grabbing spawnlocks[%s] from thread %r in function %r', irc.name, irc.name,
threading.current_thread().name, inspect.currentframe().f_code.co_name)
if spawnlocks[irc.name].acquire(timeout=TCONDITION_TIMEOUT): if spawnlocks[irc.name].acquire(timeout=TCONDITION_TIMEOUT):
# Be sort-of thread safe: lock the user spawns for the current net first. # Be sort-of thread safe: lock the user spawns for the current net first.
u = None u = None
@ -945,7 +948,8 @@ utils.add_hook(handle_join, 'PYLINK_SERVICE_JOIN')
def handle_quit(irc, numeric, command, args): def handle_quit(irc, numeric, command, args):
# Lock the user spawning mechanism before proceeding, since we're going to be # Lock the user spawning mechanism before proceeding, since we're going to be
# deleting client from the relayusers cache. # deleting client from the relayusers cache.
log.debug('(%s) Grabbing spawnlocks[%s]', irc.name, irc.name) log.debug('(%s) Grabbing spawnlocks[%s] from thread %r in function %r', irc.name, irc.name,
threading.current_thread().name, inspect.currentframe().f_code.co_name)
if spawnlocks[irc.name].acquire(timeout=TCONDITION_TIMEOUT): if spawnlocks[irc.name].acquire(timeout=TCONDITION_TIMEOUT):
for netname, user in relayusers[(irc.name, numeric)].copy().items(): for netname, user in relayusers[(irc.name, numeric)].copy().items():
remoteirc = world.networkobjects[netname] remoteirc = world.networkobjects[netname]
@ -1476,7 +1480,8 @@ def handle_disconnect(irc, numeric, command, args):
# Quit all of our users' representations on other nets, and remove # Quit all of our users' representations on other nets, and remove
# them from our relay clients index. # them from our relay clients index.
log.debug('(%s) Grabbing spawnlocks[%s]', irc.name, irc.name) log.debug('(%s) Grabbing spawnlocks[%s] from thread %r in function %r', irc.name, irc.name,
threading.current_thread().name, inspect.currentframe().f_code.co_name)
if spawnlocks[irc.name].acquire(timeout=TCONDITION_TIMEOUT): if spawnlocks[irc.name].acquire(timeout=TCONDITION_TIMEOUT):
for k, v in relayusers.copy().items(): for k, v in relayusers.copy().items():
if irc.name in v: if irc.name in v:
@ -1487,7 +1492,8 @@ def handle_disconnect(irc, numeric, command, args):
# SQUIT all relay pseudoservers spawned for us, and remove them # SQUIT all relay pseudoservers spawned for us, and remove them
# from our relay subservers index. # from our relay subservers index.
log.debug('(%s) Grabbing spawnlocks_servers[%s]', irc.name, irc.name) log.debug('(%s) Grabbing spawnlocks_servers[%s] from thread %r in function %r', irc.name, irc.name,
threading.current_thread().name, inspect.currentframe().f_code.co_name)
if spawnlocks_servers[irc.name].acquire(timeout=TCONDITION_TIMEOUT): if spawnlocks_servers[irc.name].acquire(timeout=TCONDITION_TIMEOUT):
for name, ircobj in world.networkobjects.copy().items(): for name, ircobj in world.networkobjects.copy().items():
if name != irc.name: if name != irc.name: