508 if havewx: |
508 if havewx: |
509 reactor.registerWxApp(app) |
509 reactor.registerWxApp(app) |
510 |
510 |
511 if havewx: |
511 if havewx: |
512 wx_eval_lock = Semaphore(0) |
512 wx_eval_lock = Semaphore(0) |
513 main_thread = currentThread() |
513 # main_thread = currentThread() |
514 |
514 |
515 def statuschangeTskBar(status): |
515 def statuschangeTskBar(status): |
516 wx.CallAfter(taskbar_instance.UpdateIcon, status) |
516 wx.CallAfter(taskbar_instance.UpdateIcon, status) |
517 |
517 |
518 statuschange.append(statuschangeTskBar) |
518 statuschange.append(statuschangeTskBar) |
521 tocall, args, kwargs = obj.call |
521 tocall, args, kwargs = obj.call |
522 obj.res = default_evaluator(tocall, *args, **kwargs) |
522 obj.res = default_evaluator(tocall, *args, **kwargs) |
523 wx_eval_lock.release() |
523 wx_eval_lock.release() |
524 |
524 |
525 def evaluator(tocall, *args, **kwargs): |
525 def evaluator(tocall, *args, **kwargs): |
526 if main_thread == currentThread(): |
526 # if main_thread == currentThread(): |
527 # avoid dead lock if called from the wx mainloop |
527 # # avoid dead lock if called from the wx mainloop |
528 return default_evaluator(tocall, *args, **kwargs) |
528 # return default_evaluator(tocall, *args, **kwargs) |
529 else: |
529 # else: |
530 o = type('', (object,), dict(call=(tocall, args, kwargs), res=None)) |
530 o = type('', (object,), dict(call=(tocall, args, kwargs), res=None)) |
531 wx.CallAfter(wx_evaluator, o) |
531 wx.CallAfter(wx_evaluator, o) |
532 wx_eval_lock.acquire() |
532 wx_eval_lock.acquire() |
533 return o.res |
533 return o.res |
534 |
534 |
535 pyroserver = Server(servicename, given_ip, port, |
535 pyroserver = Server(servicename, given_ip, port, |
536 WorkingDir, argv, |
536 WorkingDir, argv, |
537 statuschange, evaluator, pyruntimevars) |
537 statuschange, evaluator, pyruntimevars) |
538 |
538 |