• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python forking.Popen类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: reduce_handle

def reduce_handle(handle):
    if Popen.thread_is_spawning():
        return (None, Popen.duplicate_for_child(handle), True)
    dup_handle = duplicate(handle)
    _cache.add(dup_handle)
    sub_debug('reducing handle %d', handle)
    return (_get_listener().address, dup_handle, False)
开发者ID:Arrjaan,项目名称:Cliff,代码行数:7,代码来源:reduction.py


示例2: __getstate__

    def __getstate__(self):
        assert_spawning(self)
        r = self._reader._semlock
        w = self._writer._semlock

        reader = Popen.duplicate_for_child(r.handle), r.kind, r.maxvalue
        writer = Popen.duplicate_for_child(w.handle), w.kind, w.maxvalue
        return (reader, writer)
开发者ID:sdiehl,项目名称:numpush,代码行数:8,代码来源:shmem_sync.py


示例3: __reduce__

	def __reduce__(self):
		from multiprocessing.forking import Popen
		if not Popen.thread_is_spawning():
			raise TypeError(
				'Pickling an AuthenticationString object is '
				'disallowed for security reasons'
			)
		return AuthenticationString, (bytes(self),)
开发者ID:Fclem,项目名称:isbio,代码行数:8,代码来源:process.py


示例4: start

 def start(self):
     '''
     Start child process
     '''
     assert self._popen is None, 'cannot start a process twice'
     assert self._parent_pid == os.getpid(), \
            'can only start a process object created by current process'
     assert not _current_process._daemonic, \
            'daemonic processes are not allowed to have children'
     _cleanup()
     if self._Popen is not None:
         Popen = self._Popen
     else:
         from multiprocessing.forking import Popen
     self._popen = Popen(self)
     _current_process._children.add(self)
开发者ID:Kappie,项目名称:support_vector_machine,代码行数:16,代码来源:process.py


示例5: __getstate__

 def __getstate__(self):
     assert_spawning(self)
     sl = self._semlock
     return (Popen.duplicate_for_child(sl.handle), sl.kind, sl.maxvalue)
开发者ID:webiumsk,项目名称:WOT-0.9.12-CT,代码行数:4,代码来源:synchronize.py


示例6: Process

class Process(object):
    '''
    Process objects represent activity that is run in a separate process

    The class is analagous to `threading.Thread`
    '''
    _Popen = None

    def __init__(self, group=None, target=None, name=None, args=(), kwargs={}):
        assert group is None, 'group argument must be None for now'
        count = _current_process._counter.next()
        self._identity = _current_process._identity + (count,)
        self._authkey = _current_process._authkey
        self._daemonic = _current_process._daemonic
        self._tempdir = _current_process._tempdir
        self._parent_pid = os.getpid()
        self._popen = None
        self._target = target
        self._args = tuple(args)
        self._kwargs = dict(kwargs)
        self._name = name or type(self).__name__ + '-' + \
                     ':'.join(str(i) for i in self._identity)

    def run(self):
        '''
        Method to be run in sub-process; can be overridden in sub-class
        '''
        if self._target:
            self._target(*self._args, **self._kwargs)

    def start(self):
        '''
        Start child process
        '''
        assert self._popen is None, 'cannot start a process twice'
        assert self._parent_pid == os.getpid(), \
               'can only start a process object created by current process'
        assert not _current_process._daemonic, \
               'daemonic processes are not allowed to have children'
        _cleanup()
        if self._Popen is not None:
            Popen = self._Popen
        else:
            from multiprocessing.forking import Popen
        self._popen = Popen(self)
        _current_process._children.add(self)

    def terminate(self):
        '''
        Terminate process; sends SIGTERM signal or uses TerminateProcess()
        '''
        self._popen.terminate()

    def join(self, timeout=None):
        '''
        Wait until child process terminates
        '''
        assert self._parent_pid == os.getpid(), 'can only join a child process'
        assert self._popen is not None, 'can only join a started process'
        res = self._popen.wait(timeout)
        if res is not None:
            _current_process._children.discard(self)

    def is_alive(self):
        '''
        Return whether process is alive
        '''
        if self is _current_process:
            return True
        assert self._parent_pid == os.getpid(), 'can only test a child process'
        if self._popen is None:
            return False
        self._popen.poll()
        return self._popen.returncode is None

    @property
    def name(self):
        return self._name

    @name.setter
    def name(self, name):
        assert isinstance(name, str), 'name must be a string'
        self._name = name

    @property
    def daemon(self):
        '''
        Return whether process is a daemon
        '''
        return self._daemonic

    @daemon.setter
    def daemon(self, daemonic):
        '''
        Set whether process is a daemon
        '''
        assert self._popen is None, 'process has already started'
        self._daemonic = daemonic

    @property
#.........这里部分代码省略.........
开发者ID:Kappie,项目名称:support_vector_machine,代码行数:101,代码来源:process.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python managers.BaseManager类代码示例发布时间:2022-05-27
下一篇:
Python forking.ForkingPickler类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap