Beremiz_service.py
changeset 2249 602fdd08dfab
parent 2245 fe3394697b02
child 2270 d9175daf6522
child 2294 da288f63612f
equal deleted inserted replaced
2248:d9353e440887 2249:602fdd08dfab
    28 from __future__ import print_function
    28 from __future__ import print_function
    29 import os
    29 import os
    30 import sys
    30 import sys
    31 import getopt
    31 import getopt
    32 import threading
    32 import threading
    33 from threading import Thread, currentThread, Semaphore, Lock
    33 from threading import Thread, Semaphore, Lock
    34 import traceback
    34 import traceback
    35 import __builtin__
    35 import __builtin__
    36 import Pyro
    36 import Pyro
    37 import Pyro.core as pyro
    37 import Pyro.core as pyro
    38 
    38 
   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     # FIXME : beware wx mainloop is _not_ running in main thread
   502     # main_thread = currentThread()
   503     # main_thread = currentThread()
   503 
   504 
   504     def statuschangeTskBar(status):
   505     def statuschangeTskBar(status):
   505         wx.CallAfter(taskbar_instance.UpdateIcon, status)
   506         wx.CallAfter(taskbar_instance.UpdateIcon, status)
   506 
   507 
   510         tocall, args, kwargs = obj.call
   511         tocall, args, kwargs = obj.call
   511         obj.res = default_evaluator(tocall, *args, **kwargs)
   512         obj.res = default_evaluator(tocall, *args, **kwargs)
   512         wx_eval_lock.release()
   513         wx_eval_lock.release()
   513 
   514 
   514     def evaluator(tocall, *args, **kwargs):
   515     def evaluator(tocall, *args, **kwargs):
       
   516         # FIXME : should implement anti-deadlock
   515         # if main_thread == currentThread():
   517         # if main_thread == currentThread():
   516         #     # avoid dead lock if called from the wx mainloop
   518         #     # avoid dead lock if called from the wx mainloop
   517         #     return default_evaluator(tocall, *args, **kwargs)
   519         #     return default_evaluator(tocall, *args, **kwargs)
   518         # else:
   520         # else:
   519         o = type('', (object,), dict(call=(tocall, args, kwargs), res=None))
   521         o = type('', (object,), dict(call=(tocall, args, kwargs), res=None))