當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。