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

Python util.info函数代码示例

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

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



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

示例1: set_shared

    def set_shared(self, params, tasks, force=False):
        """Configures the mandatory shared resources.

        Updates `params`. Places tasks in `taskq`.

        Args:
            params (dict): Parameters.
            tasks (dict): Tasks.

        Keyword Args:
            force (bool): Forces task into `taskq`, regardless of whether it is already complete.

        """
        # Create a client that will the set the actual resource data.
        params["save"] = self.save
        client = SCManager(user=self.user, address=self.address,
                           authkey=self.authkey)
        client.connect()
        # Update params.
        client.params().update(params)
        # Update tasks.
        taskq = client.taskq()
        for task in tasks.itervalues():
            if force or not task.get("complete", False):
                taskq.put(task)
        util.info("[Server] Shared data successfully created.")
        del client
开发者ID:pbattaglia,项目名称:distributed,代码行数:27,代码来源:managers.py


示例2: _send_result

def _send_result(local, remote, retries):
    """Send a task's result file to remote location.

    Args:
        local (str): Path of local file.
        remote (str): Path of remote file.
        retries (int): Number of retries to perform.

    Return:
        (bool): Indicates whether send was successful.

    """
    send_str = "{} (local) > {} (remote)".format(local, remote)
    sent_pths = ()
    for r in xrange(retries):
        sent_pths = ssh.put(local, remote)
        if sent_pths.succeeded and remote in sent_pths:
            sent = True
            break
        else:
            msg = "[Client] {}/{} failed send retries ({}){{}}".format(
                r + 1, retries, send_str)
            if r + 1 < retries:
                util.info(msg.format(", retrying..."))
            else:
                util.info(msg.format(", exiting."))
    else:
        sent = False
        # sys.exit(0)  # raise NetworkError(msg.format("."))
    return sent
开发者ID:pbattaglia,项目名称:distributed,代码行数:30,代码来源:managers.py


示例3: bootstrap_2_6_6

    def bootstrap_2_6_6(self):
        """Pulled from python 2.6.6. Needed to ensure we have the fix from
        http://bugs.python.org/issue5313 when running on python version 2.6.2
        or lower."""

        try:
            self._children = set()
            self._counter = itertools.count(1)
            try:
                sys.stdin.close()
                sys.stdin = open(os.devnull)
            except (OSError, ValueError):
                pass
            multiprocessing._current_process = self
            util._finalizer_registry.clear()
            util._run_after_forkers()
            util.info("child process calling self.run()")
            try:
                self.run()
                exitcode = 0
            finally:
                util._exit_function()
        except SystemExit, e:
            if not e.args:
                exitcode = 1
            elif type(e.args[0]) is int:
                exitcode = e.args[0]
            else:
                sys.stderr.write(e.args[0] + "\n")
                sys.stderr.flush()
                exitcode = 1
开发者ID:sanyaade-embedded-systems,项目名称:bitbake,代码行数:31,代码来源:process.py


示例4: shutdown

    def shutdown(self, c):
        '''
        Shutdown this process
        '''
        try:
            try:
                util.debug('manager received shutdown message')
                c.send(('#RETURN', None))

                if sys.stdout != sys.__stdout__:
                    util.debug('resetting stdout, stderr')
                    sys.stdout = sys.__stdout__
                    sys.stderr = sys.__stderr__

                util._run_finalizers(0)

                for p in active_children():
                    util.debug('terminating a child process of manager')
                    p.terminate()

                for p in active_children():
                    util.debug('terminating a child process of manager')
                    p.join()

                util._run_finalizers()
                util.info('manager exiting with exitcode 0')
            except:
                import traceback
                traceback.print_exc()
        finally:
            exit(0)
开发者ID:vhnuuh,项目名称:pyutil,代码行数:31,代码来源:managers.py


示例5: _bootstrap

	def _bootstrap(self):
		from multiprocessing import util
		global _current_process

		try:
			self._children = set()
			self._counter = itertools.count(1)
			try:
				# sys.stdin.close()
				sys.stdin = open(os.devnull)
			except (OSError, ValueError):
				pass
			_current_process = self
			util._finalizer_registry.clear()
			util._run_after_forkers()
			util.info('child process calling self.run()')
			try:
				self.run()
				exitcode = 0
			finally:
				pass
				# util._exit_function()
		except SystemExit, e:
			if not e.args:
				exitcode = 1
			elif isinstance(e.args[0], int):
				exitcode = e.args[0]
			else:
				sys.stderr.write(str(e.args[0]) + '\n')
				sys.stderr.flush()
				exitcode = 1
开发者ID:Fclem,项目名称:isbio,代码行数:31,代码来源:process.py


示例6: _feed

    def _feed(buffer, notempty, send, 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

                        if wacquire is None:
                            send(obj)
                            # Delete references to object. See issue16284
                            del obj
                        else:
                            wacquire()
                            try:
                                send(obj)
                                # Delete references to object. See issue16284
                                del 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:Anzumana,项目名称:cpython,代码行数:60,代码来源:queues.py


示例7: _after_fork

    def _after_fork(self):
        self._manager = None
        try:
            self._incref()
        except Exception as e:
            util.info('incref failed: %s' % e)

        return
开发者ID:webiumsk,项目名称:WOT-0.9.15.1,代码行数:8,代码来源:managers.py


示例8: _feed

    def _feed(buffer, notempty, send_bytes, writelock, close, reducers,
              ignore_epipe, onerror, queue_sem):
        util.debug('starting thread to feed data to pipe')
        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

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

                        # serialize the data before acquiring the lock
                        obj_ = CustomizableLokyPickler.dumps(
                            obj, reducers=reducers)
                        if wacquire is None:
                            send_bytes(obj_)
                        else:
                            wacquire()
                            try:
                                send_bytes(obj_)
                            finally:
                                wrelease()
                        # Remove references early to avoid leaking memory
                        del obj, obj_
                except IndexError:
                    pass
            except BaseException 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.
                if util.is_exiting():
                    util.info('error in queue thread: %s', e)
                    return
                else:
                    queue_sem.release()
                    onerror(e, obj)
开发者ID:MartinThoma,项目名称:scikit-learn,代码行数:58,代码来源:queues.py


示例9: _feed

    def _feed(buffer, notempty, send, writelock, close):
        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
                        if wacquire is None:
                            send(obj)
                        else:
                            wacquire()
                            try:
                                send(obj)
                            finally:
                                wrelease()

                except IndexError:
                    pass

        except Exception as e:
            try:
                if is_exiting():
                    info('error in queue thread: %s', e)
                else:
                    import traceback
                    traceback.print_exc()
            except Exception:
                pass

        return
开发者ID:webiumsk,项目名称:WOT-0.9.15.1,代码行数:52,代码来源:queues.py


示例10: _run_server

 def _run_server(cls, registry, address, authkey, serializer, writer,
                 conn_writer, initializer=None, initargs=()):
     """ Create a server, report its address and run it."""
     if initializer is not None:
         initializer(*initargs)
     # Create server.
     server = cls._Server(registry, fqaddr(address), authkey, serializer,
                          conn_writer)
     # Inform parent process of the server's address.
     writer.send(server.address)
     writer.close()
     # Run the manager.
     util.info("Server running at {}:{}.".format(*server.address))
     server.serve_forever()
开发者ID:pbattaglia,项目名称:distributed,代码行数:14,代码来源:connection.py


示例11: _finalize_manager

 def _finalize_manager(process, address, authkey, state, conns, _Client):
     """ Shutdown the manager process; will be registered as a
     finalizer."""
     if process.is_alive():
         util.info("Sending shutdown message to manager.")
         try:
             conn = _Client(fqaddr(address), authkey=authkey)
             try:
                 dispatch(conn, None, "shutdown")
             finally:
                 conn.close()
         except Exception:
             pass
         for conn in conns:
             conn.close()
         process.join(timeout=0.2)
         if process.is_alive():
             util.info("Manager still alive.")
             if hasattr(process, "terminate"):
                 util.info("Trying to `terminate()` manager process.")
                 process.terminate()
                 process.join(timeout=0.1)
                 if process.is_alive():
                     util.info("Manager still alive after terminate.")
     state.value = State.SHUTDOWN
     try:
         del BaseProxy._address_to_local[fqaddr(address)]
     except KeyError:
         pass
开发者ID:pbattaglia,项目名称:distributed,代码行数:29,代码来源:connection.py


示例12: _finalize_manager

    def _finalize_manager(process, address, authkey, state, _Client):
        '''
        Shutdown the manager process; will be registered as a finalizer
        '''
        if process.is_alive():
            util.info('sending shutdown message to manager')
            try:
                conn = _Client(address, authkey=authkey)
                try:
                    managers.dispatch(conn, None, 'shutdown')
                finally:
                    conn.close()
            except Exception:
                pass

            process.join(timeout=0.2)
            if process.is_alive():
                util.info('manager still alive')
                if hasattr(process, 'terminate'):
                    util.info('trying to `terminate()` manager process')

                    try:
                        process.terminate()
                        process.join(timeout=0.1)
            # XXX: catch the OS error ... something weird is going on here..
                    except OSError:
                        pass
                    if process.is_alive():
                        util.info('manager still alive after terminate')

        state.value = managers.State.SHUTDOWN
        try:
            del managers.BaseProxy._address_to_local[address]
        except KeyError:
            pass
开发者ID:ncorbic,项目名称:switchy,代码行数:35,代码来源:multiproc.py


示例13: _run_server

    def _run_server(cls, registry, address, authkey, serializer, writer):
        '''
        Create a server, report its address and run it
        '''
        # create server
        server = cls._Server(registry, address, authkey, serializer)

        # inform parent process of the server's address
        writer.send(server.address)
        writer.close()

        # run the manager
        util.info('manager serving at %r', server.address)
        server.serve_forever()
开发者ID:Kappie,项目名称:support_vector_machine,代码行数:14,代码来源:managers.py


示例14: _worker_process

 def _worker_process(self, finish, job, taskq, doneq, max_run_retries=3,
                     max_send_retries=10):
     """Run a set of jobs."""
     job.setup()
     run_retries = 0
     exitcode = 0
     # Loop over tasks.
     while not taskq.empty():
         # Pop task off queue.
         task = taskq.get()
         success = False
         T0 = Time.time()
         try:
             progress, tmp_fid = job.run(task)
         except EOFError as err:
             # Report what went wrong and retry.
             util.debug("[Client] {}".format(err.msg))
             msg = "[Client] {}/{} failed run retries, {{}}".format(
                 run_retries, max_run_retries)
             if run_retries < max_run_retries:
                 run_retries += 1
                 util.debug(msg.format("retrying..."))
             else:
                 util.debug(msg.format("exiting."))
                 raise err
         else:
             # Send results.
             sent = send_result(tmp_fid, task, retries=max_send_retries)
             if sent or not self.save:
                 # Mark simulation as complete.
                 task["complete"] = True
                 # Task is done.
                 doneq.put(task)
                 success = True
                 # Report progress.
                 progress.task = (taskq.qsize(), T0.delta())
                 progress.report()
         finally:
             if not success:
                 # Task did not complete successfully: put it back in taskq.
                 taskq.put(task)
             taskq.task_done()
             exitcode = 0
             if finish.is_set():
                 exitcode = 100
                 break
     job.teardown()
     util.info("[Client] Process complete: {}.".format(ProcLabel()))
     sys.exit(exitcode)
开发者ID:pbattaglia,项目名称:distributed,代码行数:49,代码来源:managers.py


示例15: _global_after_fork

def _global_after_fork():
    # Previously every app would call:
    #    `register_after_fork(app, app._after_fork)`
    # but this created a leak as `register_after_fork` stores concrete object
    # references and once registered an object cannot be removed without
    # touching and iterating over the private afterfork registry list.
    #
    # See Issue #1949
    from celery import _state
    from multiprocessing.util import info
    for app in _state.apps:
        try:
            app._after_fork()
        except Exception as exc:
            info('after forker raised exception: %r' % (exc, ), exc_info=1)
开发者ID:SoftwareMaven,项目名称:celery,代码行数:15,代码来源:base.py


示例16: _feed

    def _feed(buffer, notempty, send, writelock, close):
        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
        wacquire = writelock.acquire
        wrelease = writelock.release

        try:
            while 1:
                try:
                    while 1:
                        obj = bpopleft()
                        if obj is sentinel:
                            debug('feeder thread got sentinel -- exiting')
                            close()
                            return

                        if wacquire is None:
                            send(obj)
                        else:
                            wacquire()
                            try:
                                send(obj)
                            finally:
                                wrelease()
                except IndexError:
                    pass
                yield "Done for now"
        except Exception as e:
            # 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:perkinslr,项目名称:pypyjs-release,代码行数:46,代码来源:queues.py


示例17: get_shared

    def get_shared(self):
        """Get shared data from server.

        Return:
            (tuple: dict, multiprocessing.JoinableQueue,
            multiprocessing.Queue, multiprocessing.JoinableQueue):
            Parameters, shared queue for tasks, shared queue for done
            tasks, shared queue for active connections.

        """
        params = self.params()
        self.Job = params["Job"]
        taskq = self.taskq()
        doneq = self.doneq()
        activeq = self.activeq()
        util.info("[Client] Received shared data.")
        # Notify the server that this client is active.
        activeq.put(self.host)
        return params, taskq, doneq, activeq
开发者ID:pbattaglia,项目名称:distributed,代码行数:19,代码来源:managers.py


示例18: start

    def start(self, params, tasks, force=False):
        """Start server.

        Args:
            params (dict): Parameters.
            tasks (dict): Tasks.

        Keyword Args:
            force (bool): Forces task into `taskq`, regardless of whether
                          it is already complete.

        """
        super(ServerManager, self).start()
        self.set_shared(params, tasks, force=force)
        # Monitor the tasks and update the tasks file as completed tasks
        # arrive from the clients.
        self.manage_tasks(tasks)
        self.shutdown()
        util.info("[Server] Jobs complete. Shutting down.")
        sys.exit(0)
开发者ID:pbattaglia,项目名称:distributed,代码行数:20,代码来源:managers.py


示例19: _malloc

    def _malloc(self, size):
        # returns a large enough block -- it might be much larger
        i = bisect.bisect_left(self._lengths, size)
        if i == len(self._lengths):
            length = self._roundup(max(self._size, size), mmap.PAGESIZE)
            self._size *= 2
            info('allocating a new mmap of length %d', length)
            arena = Arena(length)
            self._arenas.append(arena)
            return (arena, 0, length)
        else:
            length = self._lengths[i]
            seq = self._len_to_seq[length]
            block = seq.pop()
            if not seq:
                del self._len_to_seq[length], self._lengths[i]

        (arena, start, stop) = block
        del self._start_to_block[(arena, start)]
        del self._stop_to_block[(arena, stop)]
        return block
开发者ID:jitrc,项目名称:real-racer,代码行数:21,代码来源:heap.py


示例20: _spawn

    def _spawn(self, finish, params, taskq, doneq, args, kwargs):
        """Spawn a job process.

        Args:
            finish (multiprocessing.Event): Signals that process is finished.
            params (dict): Parameters.
            taskq (multiprocessing.JoinableQueue): Shared queue for tasks.
            doneq (multiprocessing.Queue): Shared queue for done tasks.
            args (tuple): Arguments for ``_worker_process``.
            kwargs (dict): Keyword arguments for ``_worker_process``.

        Return:
            (multiprocessing.Process): Worker process.

        """
        # Initialize the job.
        job = self.Job(params, *args, **kwargs)
        proc = Process(target=self._worker_process,
                       args=(finish, job, taskq, doneq))
        util.info("[Client] Spawning process: '{}'".format(proc.name))
        return proc
开发者ID:pbattaglia,项目名称:distributed,代码行数:21,代码来源:managers.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python util.log_to_stderr函数代码示例发布时间:2022-05-27
下一篇:
Python util.get_logger函数代码示例发布时间: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