久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<legend id='k97Es'><style id='k97Es'><dir id='k97Es'><q id='k97Es'></q></dir></style></legend>

  • <i id='k97Es'><tr id='k97Es'><dt id='k97Es'><q id='k97Es'><span id='k97Es'><b id='k97Es'><form id='k97Es'><ins id='k97Es'></ins><ul id='k97Es'></ul><sub id='k97Es'></sub></form><legend id='k97Es'></legend><bdo id='k97Es'><pre id='k97Es'><center id='k97Es'></center></pre></bdo></b><th id='k97Es'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='k97Es'><tfoot id='k97Es'></tfoot><dl id='k97Es'><fieldset id='k97Es'></fieldset></dl></div>
    • <bdo id='k97Es'></bdo><ul id='k97Es'></ul>
      <tfoot id='k97Es'></tfoot>
      1. <small id='k97Es'></small><noframes id='k97Es'>

        python multiprocessing BaseManager注冊類在Ctrl-C后立即失

        python multiprocessing BaseManager registered class lost connection immediately after Ctrl-C(python multiprocessing BaseManager注冊類在Ctrl-C后立即失去連接)
      2. <i id='Kpus8'><tr id='Kpus8'><dt id='Kpus8'><q id='Kpus8'><span id='Kpus8'><b id='Kpus8'><form id='Kpus8'><ins id='Kpus8'></ins><ul id='Kpus8'></ul><sub id='Kpus8'></sub></form><legend id='Kpus8'></legend><bdo id='Kpus8'><pre id='Kpus8'><center id='Kpus8'></center></pre></bdo></b><th id='Kpus8'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Kpus8'><tfoot id='Kpus8'></tfoot><dl id='Kpus8'><fieldset id='Kpus8'></fieldset></dl></div>
          <bdo id='Kpus8'></bdo><ul id='Kpus8'></ul>
          <tfoot id='Kpus8'></tfoot>

            <tbody id='Kpus8'></tbody>

              <small id='Kpus8'></small><noframes id='Kpus8'>

                <legend id='Kpus8'><style id='Kpus8'><dir id='Kpus8'><q id='Kpus8'></q></dir></style></legend>

                • 本文介紹了python multiprocessing BaseManager注冊類在Ctrl-C后立即失去連接的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我遇到了一些我懷疑是我的 python 程序無法正確處理的問題,我的程序無法在按下 Ctrl-C 后立即調(diào)用 BaseManager 注冊類的方法,即使其他進程實現(xiàn)為從 multiprocessing.Process 繼承的類會受到影響.我有一些我想從 Ctrl-C 后無法正確執(zhí)行的進程調(diào)用的方法.

                  I am experiencing some issues that I suspect is a limitation of my python program to handle correctly, my program is not been able to call methods of a registered class of BaseManager immediately after I hit Ctrl-C, even other process implemented as classes that inherit from multiprocessing.Process are affected. I have some methods that I would like to call from process that don't execute correctly after Ctrl-C.

                  例如下面的代碼在Ctrl-C之后不能調(diào)用TestClass的mt實例.

                  For example the following code is not able to call the mt instance of TestClass after Ctrl-C.

                  from multiprocessing.managers import BaseManager, NamespaceProxy
                  import time
                  
                  class TestClass(object):
                      def __init__(self, a):
                          self.a = a
                  
                      def b(self):
                          print self.a
                  
                  class MyManager(BaseManager): pass
                  
                  class TestProxy(NamespaceProxy):
                      # We need to expose the same __dunder__ methods as NamespaceProxy,
                      # in addition to the b method.
                      _exposed_ = ('__getattribute__', '__setattr__', '__delattr__', 'b')
                  
                      def b(self):
                          callmethod = object.__getattribute__(self, '_callmethod')
                          return callmethod('b')
                  
                  MyManager.register('TestClass', TestClass, TestProxy)
                  
                  if __name__ == '__main__':
                      manager = MyManager()
                      manager.start()
                      t = TestClass(1)
                      print t.a
                      mt = manager.TestClass(2)
                      print mt.a
                      mt.a = 5
                      mt.b()
                  
                      try:
                          while 1:
                              pass
                      except (KeyboardInterrupt, SystemExit):
                          time.sleep(0.1)
                          mt.a = 7
                          mt.b()
                          print "bye"
                          pass
                  
                  Here is the console output
                  
                  1
                  2
                  5
                  ^CTraceback (most recent call last):
                    File "testManager.py", line 38, in <module>
                      mt.a = 7
                    File "/usr/lib/python2.7/multiprocessing/managers.py", line 1028, in __setattr__
                      return callmethod('__setattr__', (key, value))
                    File "/usr/lib/python2.7/multiprocessing/managers.py", line 758, in _callmethod
                      conn.send((self._id, methodname, args, kwds))
                  IOError: [Errno 32] Broken pipe
                  

                  你有什么建議嗎?我的代碼中是否有任何解決方法或問題?

                  Do you have any suggestion? Is there any workaround or something wrong in my code?

                  提前致謝.

                  推薦答案

                  如果有人遇到這個問題,我根據(jù)這個答案解決了 https://stackoverflow.com/a/21106459/1667319.這是工作代碼

                  If someone happen to had this issue, I solved based on this answer https://stackoverflow.com/a/21106459/1667319 . Here is the working code

                  from multiprocessing.managers import SyncManager, NamespaceProxy
                  import time
                  import signal
                  
                  #handle SIGINT from SyncManager object
                  def mgr_sig_handler(signal, frame):
                      print 'not closing the mgr'
                  
                  #initilizer for SyncManager
                  def mgr_init():
                      signal.signal(signal.SIGINT, mgr_sig_handler)
                      #signal.signal(signal.SIGINT, signal.SIG_IGN) # <- OR do this to just ignore the signal
                      print 'initialized mananger'
                  
                  class TestClass(object):
                      def __init__(self, a):
                          self.a = a
                  
                      def b(self):
                          print self.a
                  
                  class MyManager(SyncManager): pass
                  
                  class TestProxy(NamespaceProxy):
                      # We need to expose the same __dunder__ methods as NamespaceProxy,
                      # in addition to the b method.
                      _exposed_ = ('__getattribute__', '__setattr__', '__delattr__', 'b')
                  
                      def b(self):
                          callmethod = object.__getattribute__(self, '_callmethod')
                          return callmethod('b')
                  
                  MyManager.register('TestClass', TestClass, TestProxy)
                  
                  if __name__ == '__main__':
                      manager = MyManager()
                      manager.start(mgr_init)
                      t = TestClass(1)
                      print t.a
                      mt = manager.TestClass(2)
                      print mt.a
                      mt.a = 5
                      mt.b()
                      try:
                          while 1:
                              pass
                      except (KeyboardInterrupt, SystemExit):
                          time.sleep(0.1)
                          mt.a = 7
                          mt.b()
                          print "bye"
                          pass
                  

                  干杯,

                  這篇關(guān)于python multiprocessing BaseManager注冊類在Ctrl-C后立即失去連接的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  What exactly is Python multiprocessing Module#39;s .join() Method Doing?(Python 多處理模塊的 .join() 方法到底在做什么?)
                  Passing multiple parameters to pool.map() function in Python(在 Python 中將多個參數(shù)傳遞給 pool.map() 函數(shù))
                  multiprocessing.pool.MaybeEncodingError: #39;TypeError(quot;cannot serialize #39;_io.BufferedReader#39; objectquot;,)#39;(multiprocessing.pool.MaybeEncodingError: TypeError(cannot serialize _io.BufferedReader object,)) - IT屋-程序員軟件開
                  Python Multiprocess Pool. How to exit the script when one of the worker process determines no more work needs to be done?(Python 多進程池.當(dāng)其中一個工作進程確定不再需要完成工作時,如何退出腳本?) - IT屋-程序員
                  How do you pass a Queue reference to a function managed by pool.map_async()?(如何將隊列引用傳遞給 pool.map_async() 管理的函數(shù)?)
                  yet another confusion with multiprocessing error, #39;module#39; object has no attribute #39;f#39;(與多處理錯誤的另一個混淆,“模塊對象沒有屬性“f)

                  <i id='kffuT'><tr id='kffuT'><dt id='kffuT'><q id='kffuT'><span id='kffuT'><b id='kffuT'><form id='kffuT'><ins id='kffuT'></ins><ul id='kffuT'></ul><sub id='kffuT'></sub></form><legend id='kffuT'></legend><bdo id='kffuT'><pre id='kffuT'><center id='kffuT'></center></pre></bdo></b><th id='kffuT'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='kffuT'><tfoot id='kffuT'></tfoot><dl id='kffuT'><fieldset id='kffuT'></fieldset></dl></div>
                • <tfoot id='kffuT'></tfoot>
                    <tbody id='kffuT'></tbody>

                      • <bdo id='kffuT'></bdo><ul id='kffuT'></ul>

                          <small id='kffuT'></small><noframes id='kffuT'>

                            <legend id='kffuT'><style id='kffuT'><dir id='kffuT'><q id='kffuT'></q></dir></style></legend>
                            主站蜘蛛池模板: 伊人热久久 | 午夜免费在线观看 | 日本三级电影免费 | 黄色高清视频 | 一级欧美黄色片 | 亚洲成人精品 | 亚洲九色| 午夜激情视频 | 免费看片国产 | 久久99久久久久 | 欧美在线日韩 | 中文字幕一区在线观看视频 | 久久精品亚洲 | 国内自拍偷拍 | 日本91av视频 | 日韩一区二区三区在线观看 | 欧美亚洲视频 | 欧美日韩综合 | 亚州精品天堂中文字幕 | 免费a网| 超碰成人av | 九一精品 | 国产精品久久久久久久久免费软件 | 偷派自拍 | 九热在线 | 亚洲一区在线日韩在线深爱 | 久久精品国产一区二区三区不卡 | 欧洲视频一区二区 | a黄毛片| 天啪 | 美国av毛片| 国产在线播 | 蜜桃一区| 亚洲精品久久久久久一区二区 | 91久久精品日日躁夜夜躁国产 | 成人免费在线电影 | 久久久蜜桃| 国产 日韩 欧美 制服 另类 | 福利片在线观看 | 91热在线| 国产精品久久久久久av公交车 |