当前位置: 首页>>代码示例>>Python>>正文


Python ForkingPickler.dumps方法代码示例

本文整理汇总了Python中multiprocessing.forking.ForkingPickler.dumps方法的典型用法代码示例。如果您正苦于以下问题:Python ForkingPickler.dumps方法的具体用法?Python ForkingPickler.dumps怎么用?Python ForkingPickler.dumps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在multiprocessing.forking.ForkingPickler的用法示例。


在下文中一共展示了ForkingPickler.dumps方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _feed

# 需要导入模块: from multiprocessing.forking import ForkingPickler [as 别名]
# 或者: from multiprocessing.forking.ForkingPickler import dumps [as 别名]
    def _feed(buffer, notempty, send_bytes, writelock, close, ignore_epipe):
        debug('starting thread to feed data to pipe')
        from .util import is_exiting

        nacquire = notempty.acquire
        nrelease = notempty.release
        nwait = notempty.wait
        bpopleft = buffer.popleft
        sentinel = _sentinel
        if sys.platform != 'win32':
            wacquire = writelock.acquire
            wrelease = writelock.release
        else:
            wacquire = None

        try:
            while 1:
                nacquire()
                try:
                    if not buffer:
                        nwait()
                finally:
                    nrelease()
                try:
                    while 1:
                        obj = bpopleft()
                        if obj is sentinel:
                            debug('feeder thread got sentinel -- exiting')
                            close()
                            return

                        # serialize the data before acquiring the lock
                        obj = ForkingPickler.dumps(obj)
                        if wacquire is None:
                            send_bytes(obj)
                        else:
                            wacquire()
                            try:
                                send_bytes(obj)
                            finally:
                                wrelease()
                except IndexError:
                    pass
        except Exception as e:
            if ignore_epipe and getattr(e, 'errno', 0) == errno.EPIPE:
                return
            # Since this runs in a daemon thread the resources it uses
            # may be become unusable while the process is cleaning up.
            # We ignore errors which happen after the process has
            # started to cleanup.
            try:
                if is_exiting():
                    info('error in queue thread: %s', e)
                else:
                    import traceback
                    traceback.print_exc()
            except Exception:
                pass
开发者ID:524777134,项目名称:cpython,代码行数:60,代码来源:queues.py

示例2: put

# 需要导入模块: from multiprocessing.forking import ForkingPickler [as 别名]
# 或者: from multiprocessing.forking.ForkingPickler import dumps [as 别名]
 def put(self, obj):
     # serialize the data before acquiring the lock
     obj = ForkingPickler.dumps(obj)
     if self._wlock is None:
         # writes to a message oriented win32 pipe are atomic
         self._writer.send_bytes(obj)
     else:
         with self._wlock:
             self._writer.send_bytes(obj)
开发者ID:524777134,项目名称:cpython,代码行数:11,代码来源:queues.py

示例3: send

# 需要导入模块: from multiprocessing.forking import ForkingPickler [as 别名]
# 或者: from multiprocessing.forking.ForkingPickler import dumps [as 别名]
 def send(self, obj):
     """Send a (picklable) object"""
     self._check_closed()
     self._check_writable()
     self._send_bytes(ForkingPickler.dumps(obj))
开发者ID:jadore,项目名称:cpython,代码行数:7,代码来源:connection.py


注:本文中的multiprocessing.forking.ForkingPickler.dumps方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。