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


Python multiprocessing.get_logger方法代码示例

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


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

示例1: main

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import get_logger [as 别名]
def main():
    """Starts several processes

    This must be kept to the bare minimum
    """
    multiprocessing.log_to_stderr()
    logger = multiprocessing.get_logger()
    logger.setLevel(logging.INFO)

    jobs = []

    try:
        bfs = BrundleFuzzServer()
        jobs.append(bfs)
        bfs.start()

        for j in jobs:
            j.join()

    except KeyboardInterrupt:
        pass 
开发者ID:carlosgprado,项目名称:BrundleFuzz,代码行数:23,代码来源:BrundleFuzzServer.py

示例2: __init__

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import get_logger [as 别名]
def __init__(self, mem_in_mb=None, cpu_time_in_s=None, wall_time_in_s=None, num_processes=None, grace_period_in_s = None, logger = None, capture_output=False):
		self.mem_in_mb = mem_in_mb
		self.cpu_time_in_s = cpu_time_in_s
		self.num_processes = num_processes
		self.wall_time_in_s = wall_time_in_s
		self.grace_period_in_s = 0 if grace_period_in_s is None else grace_period_in_s
		self.logger = logger if logger is not None else multiprocessing.get_logger()
		self.capture_output = capture_output
		
		if self.mem_in_mb is not None:
			self.logger.debug("Restricting your function to {} mb memory.".format(self.mem_in_mb))
		if self.cpu_time_in_s is not None:
			self.logger.debug("Restricting your function to {} seconds cpu time.".format(self.cpu_time_in_s))
		if self.wall_time_in_s is not None:
			self.logger.debug("Restricting your function to {} seconds wall time.".format(self.wall_time_in_s))
		if self.num_processes is not None:
			self.logger.debug("Restricting your function to {} threads/processes.".format(self.num_processes))
		if self.grace_period_in_s is not None:
			self.logger.debug("Allowing a grace period of {} seconds.".format(self.grace_period_in_s)) 
开发者ID:sfalkner,项目名称:pynisher,代码行数:21,代码来源:limit_function_call.py

示例3: __call__

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import get_logger [as 别名]
def __call__(self, *args, **kwargs):
        try:
            result = self.__callable(*args, **kwargs)
        except Exception:
            # Here we add some debugging help. If multiprocessing's
            # debugging is on, it will arrange to log the traceback
            logger = multiprocessing.get_logger()
            if not logger.handlers:
                logger.addHandler(logging.StreamHandler())
            logger.error(traceback.format_exc())
            logger.handlers[0].flush()
            # Re-raise the original exception so the Pool worker can
            # clean up
            raise

        # It was fine, give a normal answer
        return result 
开发者ID:CleanCut,项目名称:green,代码行数:19,代码来源:process.py

示例4: error

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import get_logger [as 别名]
def error(msg, *args):
    return multiprocessing.get_logger().error(msg, *args) 
开发者ID:ShailChoksi,项目名称:lichess-bot,代码行数:4,代码来源:logging_pool.py

示例5: getProcessSafeLogger

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import get_logger [as 别名]
def getProcessSafeLogger(logPath):
	if multiprocessing.current_process().name == "MainProcess":
		return logging.getLogger(logPath)
	else:
		return multiprocessing.get_logger(logPath) 
开发者ID:fake-name,项目名称:ReadableWebProxy,代码行数:7,代码来源:logSetup.py

示例6: test_enable_logging

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import get_logger [as 别名]
def test_enable_logging(self):
        logger = multiprocessing.get_logger()
        logger.setLevel(util.SUBWARNING)
        self.assertTrue(logger is not None)
        logger.debug('this will not be printed')
        logger.info('nor will this')
        logger.setLevel(LOG_LEVEL) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_multiprocessing.py

示例7: _test_level

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import get_logger [as 别名]
def _test_level(cls, conn):
        logger = multiprocessing.get_logger()
        conn.send(logger.getEffectiveLevel()) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_multiprocessing.py

示例8: Sniffer

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import get_logger [as 别名]
def Sniffer(packetList, e):
    logger = multiprocessing.get_logger()
    snifferSocket = socket.socket(
        socket.AF_PACKET,
        socket.SOCK_RAW,
        socket.ntohs(0x0003)
    )
    snifferSocket.bind((options['interface'], 0))

    logger.info("Sniffer and process packets, Press Ctrl-C to stop.")

    while True:
        packets = snifferSocket.recvfrom(65535)
        packet = packets[0]
        ethernetFrame = EthernetFrame()
        ethernetFrame.Decode(packet)

        if ethernetFrame.ethProto == 8:
            ipPacket = IPv4Packet()
            ipPacket.Decode(ethernetFrame.payload)

            if ipPacket.ipProtocol == 6:
                tcpPacket = TCPPacket()
                tcpPacket.Decode(ipPacket.payload)
            else:
                continue

        else:
            continue

        packetDic = MergeDicts(ethernetFrame.GetEthernetHeaderDic(), ipPacket.GetIpv4HeaderDic(),
                               tcpPacket.GetTcpHeaderDic())
        logger.debug(packetDic)
        snifferFilter = Filter(packetDic, options)
        if snifferFilter.run() is True:
            continue
        print packetDic
        packetList.append(packetDic)
        e.set()

    snifferSocket.close() 
开发者ID:openweave,项目名称:happy,代码行数:43,代码来源:HappyPacketProcess.py

示例9: create_logger

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import get_logger [as 别名]
def create_logger():
    logger = multiprocessing.get_logger()
    logger.setLevel(logging.INFO)
    fh = logging.FileHandler('process.log')
    fmt = '%(asctime)s - %(levelname)s - %(message)s'
    formatter = logging.Formatter(fmt)
    fh.setFormatter(formatter)
    logger.addHandler(fh)
    return logger 
开发者ID:testdrivenio,项目名称:simple-task-queue,代码行数:11,代码来源:simple_task_queue_logging.py

示例10: create_logger

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import get_logger [as 别名]
def create_logger(pid):
    logger = multiprocessing.get_logger()
    logger.setLevel(logging.INFO)
    fh = logging.FileHandler(f'logs/process_{pid}.log')
    fmt = '%(asctime)s - %(levelname)s - %(message)s'
    formatter = logging.Formatter(fmt)
    fh.setFormatter(formatter)
    logger.addHandler(fh)
    return logger 
开发者ID:testdrivenio,项目名称:simple-task-queue,代码行数:11,代码来源:simple_task_queue_logging_separate_files.py

示例11: __init__

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import get_logger [as 别名]
def __init__(self, blockchain, mempool):
        mp.log_to_stderr()
        mp_logger = mp.get_logger()
        mp_logger.setLevel(logging.DEBUG)
        self.blockchain = blockchain
        self.mempool = mempool 
开发者ID:cranklin,项目名称:crankycoin,代码行数:8,代码来源:miner.py

示例12: __init__

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import get_logger [as 别名]
def __init__(self, peers, api_client, blockchain, mempool, validator):
        super(FullNode, self).__init__(peers, api_client)
        mp.log_to_stderr()
        mp_logger = mp.get_logger()
        mp_logger.setLevel(logging.DEBUG)
        self.app = Bottle()
        self.app.merge(public_app)
        self.app.merge(permissioned_app)
        self.blockchain = blockchain
        self.mempool = mempool
        self.validator = validator 
开发者ID:cranklin,项目名称:crankycoin,代码行数:13,代码来源:node.py

示例13: test_level

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import get_logger [as 别名]
def test_level(self):
        LEVEL1 = 32
        LEVEL2 = 37

        logger = multiprocessing.get_logger()
        root_logger = logging.getLogger()
        root_level = root_logger.level

        reader, writer = multiprocessing.Pipe(duplex=False)

        logger.setLevel(LEVEL1)
        p = self.Process(target=self._test_level, args=(writer,))
        p.daemon = True
        p.start()
        self.assertEqual(LEVEL1, reader.recv())

        logger.setLevel(logging.NOTSET)
        root_logger.setLevel(LEVEL2)
        p = self.Process(target=self._test_level, args=(writer,))
        p.daemon = True
        p.start()
        self.assertEqual(LEVEL2, reader.recv())

        root_logger.setLevel(root_level)
        logger.setLevel(level=LOG_LEVEL)


# class _TestLoggingProcessName(BaseTestCase):
#
#     def handle(self, record):
#         assert record.processName == multiprocessing.current_process().name
#         self.__handled = True
#
#     def test_logging(self):
#         handler = logging.Handler()
#         handler.handle = self.handle
#         self.__handled = False
#         # Bypass getLogger() and side-effects
#         logger = logging.getLoggerClass()(
#                 'multiprocessing.test.TestLoggingProcessName')
#         logger.addHandler(handler)
#         logger.propagate = False
#
#         logger.warn('foo')
#         assert self.__handled

#
# Check that Process.join() retries if os.waitpid() fails with EINTR
# 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:51,代码来源:test_multiprocessing.py

示例14: test_main

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import get_logger [as 别名]
def test_main(run=None):
    if sys.platform.startswith("linux"):
        try:
            lock = multiprocessing.RLock()
        except OSError:
            raise unittest.SkipTest("OSError raises on RLock creation, see issue 3111!")

    check_enough_semaphores()

    if run is None:
        from test.support import run_unittest as run

    util.get_temp_dir()     # creates temp directory for use by all processes

    multiprocessing.get_logger().setLevel(LOG_LEVEL)

    ProcessesMixin.pool = multiprocessing.Pool(4)
    ThreadsMixin.pool = multiprocessing.dummy.Pool(4)
    ManagerMixin.manager.__init__()
    ManagerMixin.manager.start()
    ManagerMixin.pool = ManagerMixin.manager.Pool(4)

    testcases = (
        sorted(testcases_processes.values(), key=lambda tc:tc.__name__) +
        sorted(testcases_threads.values(), key=lambda tc:tc.__name__) +
        sorted(testcases_manager.values(), key=lambda tc:tc.__name__) +
        testcases_other
        )

    loadTestsFromTestCase = unittest.defaultTestLoader.loadTestsFromTestCase
    suite = unittest.TestSuite(loadTestsFromTestCase(tc) for tc in testcases)
    # (ncoghlan): Whether or not sys.exc_clear is executed by the threading
    # module during these tests is at least platform dependent and possibly
    # non-deterministic on any given platform. So we don't mind if the listed
    # warnings aren't actually raised.
    with support.check_py3k_warnings(
            (".+__(get|set)slice__ has been removed", DeprecationWarning),
            (r"sys.exc_clear\(\) not supported", DeprecationWarning),
            quiet=True):
        run(suite)

    ThreadsMixin.pool.terminate()
    ProcessesMixin.pool.terminate()
    ManagerMixin.pool.terminate()
    ManagerMixin.manager.shutdown()

    del ProcessesMixin.pool, ThreadsMixin.pool, ManagerMixin.pool 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:49,代码来源:test_multiprocessing.py


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