vendredi 30 mai 2014

Shared variable in Python Process subclass


Vote count:

0




I was wondering if it would be possible to create some sort of static set in a Python Process subclass to keep track the types processes that are currently running asynchronously.



class showError(Process):
# Define some form of shared set that is shared by all Processes
displayed_errors = set()

def __init__(self, file_name, error_type):
super(showError, self).__init__()
self.error_type = error_type

def run(self):
if error_type not in set:
displayed_errors.add(error_type)
message = 'Please try again. ' + str(self.error_type)
winsound.MessageBeep(-1)
result = win32api.MessageBox(0, message, 'Error', 0x00001000)

if result == 0:
displayed_errors.discard(error_type)


That way, when I create/start multiple showError processes with the same error_type, subsequent error windows will not be created.



asked 13 secs ago






Aucun commentaire:

Enregistrer un commentaire