久久久久久久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 注冊類的方法,即使其他進(jìn)程實(shí)現(xiàn)為從 multiprocessing.Process 繼承的類會受到影響.我有一些我想從 Ctrl-C 后無法正確執(zhí)行的進(jìn)程調(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實(shí)例.

                  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 多進(jìn)程池.當(dāng)其中一個工作進(jìn)程確定不再需要完成工作時,如何退出腳本?) - 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>
                            主站蜘蛛池模板: 一区二区三区日韩精品 | a视频在线观看 | 国产一区二区不卡 | av无遮挡 | 欧美激情在线播放 | av在线播放免费 | 狠狠狠色丁香婷婷综合久久五月 | 欧美日本一区 | 亚洲免费一区 | 久久久www成人免费精品张筱雨 | 激情五月婷婷丁香 | 国产欧美精品一区二区色综合朱莉 | 中文字幕日韩一区 | 动漫www.被爆羞羞av44 | 色综合久久88色综合天天 | 爱爱视频网 | 日韩亚洲视频 | 精品日韩| 欧美亚洲网站 | 成人黄色在线观看 | 一区二区国产精品 | 欧美福利久久 | 久久久久国产精品一区二区 | 精品国产乱码久久久久久果冻传媒 | 亚洲成人免费 | 97超级碰碰 | 久久久久亚洲精品中文字幕 | 欧美国产日韩一区二区三区 | 中文字幕 国产 | 亚洲国产精品一区二区久久 | 不卡一区二区三区四区 | 久久国品片 | 欧美精产国品一二三区 | 色视频网站在线观看 | 亚洲国产一区在线 | 伊人网站视频 | 精品国产伦一区二区三区观看说明 | 亚洲精品国产偷自在线观看 | 我我色综合 | 一区二区三区视频播放 | 国产最好的av国产大片 |