|
1 |
| -# Copyright 2001-2022 by Vinay Sajip. All Rights Reserved. |
| 1 | +# Copyright 2001-2023 by Vinay Sajip. All Rights Reserved. |
2 | 2 | #
|
3 | 3 | # Permission to use, copy, modify, and distribute this software and its
|
4 | 4 | # documentation for any purpose and without fee is hereby granted,
|
@@ -734,7 +734,7 @@ def _configure_queue_handler(self, klass, **kwargs):
|
734 | 734 | lklass = kwargs['listener']
|
735 | 735 | else:
|
736 | 736 | lklass = logging.handlers.QueueListener
|
737 |
| - listener = lklass(q, *kwargs['handlers'], respect_handler_level=rhl) |
| 737 | + listener = lklass(q, *kwargs.get('handlers', []), respect_handler_level=rhl) |
738 | 738 | handler = klass(q)
|
739 | 739 | handler.listener = listener
|
740 | 740 | return handler
|
@@ -776,11 +776,12 @@ def configure_handler(self, config):
|
776 | 776 | raise ValueError('Unable to set target handler %r' % tn) from e
|
777 | 777 | elif issubclass(klass, logging.handlers.QueueHandler):
|
778 | 778 | # Another special case for handler which refers to other handlers
|
779 |
| - if 'handlers' not in config: |
780 |
| - raise ValueError('No handlers specified for a QueueHandler') |
| 779 | + # if 'handlers' not in config: |
| 780 | + # raise ValueError('No handlers specified for a QueueHandler') |
781 | 781 | if 'queue' in config:
|
| 782 | + from multiprocessing.queues import Queue as MPQueue |
782 | 783 | qspec = config['queue']
|
783 |
| - if not isinstance(qspec, queue.Queue): |
| 784 | + if not isinstance(qspec, (queue.Queue, MPQueue)): |
784 | 785 | if isinstance(qspec, str):
|
785 | 786 | q = self.resolve(qspec)
|
786 | 787 | if not callable(q):
|
@@ -813,18 +814,19 @@ def configure_handler(self, config):
|
813 | 814 | if not callable(listener):
|
814 | 815 | raise TypeError('Invalid listener specifier %r' % lspec)
|
815 | 816 | config['listener'] = listener
|
816 |
| - hlist = [] |
817 |
| - try: |
818 |
| - for hn in config['handlers']: |
819 |
| - h = self.config['handlers'][hn] |
820 |
| - if not isinstance(h, logging.Handler): |
821 |
| - config.update(config_copy) # restore for deferred cfg |
822 |
| - raise TypeError('Required handler %r ' |
823 |
| - 'is not configured yet' % hn) |
824 |
| - hlist.append(h) |
825 |
| - except Exception as e: |
826 |
| - raise ValueError('Unable to set required handler %r' % hn) from e |
827 |
| - config['handlers'] = hlist |
| 817 | + if 'handlers' in config: |
| 818 | + hlist = [] |
| 819 | + try: |
| 820 | + for hn in config['handlers']: |
| 821 | + h = self.config['handlers'][hn] |
| 822 | + if not isinstance(h, logging.Handler): |
| 823 | + config.update(config_copy) # restore for deferred cfg |
| 824 | + raise TypeError('Required handler %r ' |
| 825 | + 'is not configured yet' % hn) |
| 826 | + hlist.append(h) |
| 827 | + except Exception as e: |
| 828 | + raise ValueError('Unable to set required handler %r' % hn) from e |
| 829 | + config['handlers'] = hlist |
828 | 830 | elif issubclass(klass, logging.handlers.SMTPHandler) and\
|
829 | 831 | 'mailhost' in config:
|
830 | 832 | config['mailhost'] = self.as_tuple(config['mailhost'])
|
|
0 commit comments