497 if havewx: |
497 if havewx: |
498 reactor.registerWxApp(app) |
498 reactor.registerWxApp(app) |
499 |
499 |
500 if havewx: |
500 if havewx: |
501 wx_eval_lock = Semaphore(0) |
501 wx_eval_lock = Semaphore(0) |
502 main_thread = currentThread() |
502 # main_thread = currentThread() |
503 |
503 |
504 def statuschangeTskBar(status): |
504 def statuschangeTskBar(status): |
505 wx.CallAfter(taskbar_instance.UpdateIcon, status) |
505 wx.CallAfter(taskbar_instance.UpdateIcon, status) |
506 |
506 |
507 statuschange.append(statuschangeTskBar) |
507 statuschange.append(statuschangeTskBar) |
510 tocall, args, kwargs = obj.call |
510 tocall, args, kwargs = obj.call |
511 obj.res = default_evaluator(tocall, *args, **kwargs) |
511 obj.res = default_evaluator(tocall, *args, **kwargs) |
512 wx_eval_lock.release() |
512 wx_eval_lock.release() |
513 |
513 |
514 def evaluator(tocall, *args, **kwargs): |
514 def evaluator(tocall, *args, **kwargs): |
515 if main_thread == currentThread(): |
515 # if main_thread == currentThread(): |
516 # avoid dead lock if called from the wx mainloop |
516 # # avoid dead lock if called from the wx mainloop |
517 return default_evaluator(tocall, *args, **kwargs) |
517 # return default_evaluator(tocall, *args, **kwargs) |
518 else: |
518 # else: |
519 o = type('', (object,), dict(call=(tocall, args, kwargs), res=None)) |
519 o = type('', (object,), dict(call=(tocall, args, kwargs), res=None)) |
520 wx.CallAfter(wx_evaluator, o) |
520 wx.CallAfter(wx_evaluator, o) |
521 wx_eval_lock.acquire() |
521 wx_eval_lock.acquire() |
522 return o.res |
522 return o.res |
523 |
523 |
524 pyroserver = Server(servicename, given_ip, port, |
524 pyroserver = Server(servicename, given_ip, port, |
525 WorkingDir, argv, |
525 WorkingDir, argv, |
526 statuschange, evaluator, pyruntimevars) |
526 statuschange, evaluator, pyruntimevars) |
527 |
527 |