Sending commands to running python progress -
i want communicate server clients tcp server. question regarding (resp. common method) send bytes client different thread, e.g. when calls python script web. there way accomplish this?
you can define member variable threads created when client connected. use lock write variable. variable shared threads :
import threading class connectedclients(threading.thread): used_ressources = list() used_ressources_lock = threading.lock() def run(self, ressource_to_get): if ressource_to_get in used_ressources: raise exception('already used ressource:' + repr(ressource_to_get)) else: can_access = self.used_ressources_lock.acquire(blocking=true, timeout=5) if can_access: self.used_ressources.append(ressource_to_get) self.used_ressources_lock.release() # something... # have acquire lock , remove ressource # list when you're done it. else: raise exception("cannot acquire lock")
is looking ?
Comments
Post a Comment