|
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,
|
@@ -740,7 +740,7 @@ def _configure_queue_handler(self, klass, **kwargs):
|
740 | 740 | lklass = kwargs['listener']
|
741 | 741 | else:
|
742 | 742 | lklass = logging.handlers.QueueListener
|
743 |
| - listener = lklass(q, *kwargs['handlers'], respect_handler_level=rhl) |
| 743 | + listener = lklass(q, *kwargs.get('handlers', []), respect_handler_level=rhl) |
744 | 744 | handler = klass(q)
|
745 | 745 | handler.listener = listener
|
746 | 746 | return handler
|
@@ -782,11 +782,12 @@ def configure_handler(self, config):
|
782 | 782 | raise ValueError('Unable to set target handler %r' % tn) from e
|
783 | 783 | elif issubclass(klass, logging.handlers.QueueHandler):
|
784 | 784 | # Another special case for handler which refers to other handlers
|
785 |
| - if 'handlers' not in config: |
786 |
| - raise ValueError('No handlers specified for a QueueHandler') |
| 785 | + # if 'handlers' not in config: |
| 786 | + # raise ValueError('No handlers specified for a QueueHandler') |
787 | 787 | if 'queue' in config:
|
| 788 | + from multiprocessing.queues import Queue as MPQueue |
788 | 789 | qspec = config['queue']
|
789 |
| - if not isinstance(qspec, queue.Queue): |
| 790 | + if not isinstance(qspec, (queue.Queue, MPQueue)): |
790 | 791 | if isinstance(qspec, str):
|
791 | 792 | q = self.resolve(qspec)
|
792 | 793 | if not callable(q):
|
@@ -819,18 +820,19 @@ def configure_handler(self, config):
|
819 | 820 | if not callable(listener):
|
820 | 821 | raise TypeError('Invalid listener specifier %r' % lspec)
|
821 | 822 | config['listener'] = listener
|
822 |
| - hlist = [] |
823 |
| - try: |
824 |
| - for hn in config['handlers']: |
825 |
| - h = self.config['handlers'][hn] |
826 |
| - if not isinstance(h, logging.Handler): |
827 |
| - config.update(config_copy) # restore for deferred cfg |
828 |
| - raise TypeError('Required handler %r ' |
829 |
| - 'is not configured yet' % hn) |
830 |
| - hlist.append(h) |
831 |
| - except Exception as e: |
832 |
| - raise ValueError('Unable to set required handler %r' % hn) from e |
833 |
| - config['handlers'] = hlist |
| 823 | + if 'handlers' in config: |
| 824 | + hlist = [] |
| 825 | + try: |
| 826 | + for hn in config['handlers']: |
| 827 | + h = self.config['handlers'][hn] |
| 828 | + if not isinstance(h, logging.Handler): |
| 829 | + config.update(config_copy) # restore for deferred cfg |
| 830 | + raise TypeError('Required handler %r ' |
| 831 | + 'is not configured yet' % hn) |
| 832 | + hlist.append(h) |
| 833 | + except Exception as e: |
| 834 | + raise ValueError('Unable to set required handler %r' % hn) from e |
| 835 | + config['handlers'] = hlist |
834 | 836 | elif issubclass(klass, logging.handlers.SMTPHandler) and\
|
835 | 837 | 'mailhost' in config:
|
836 | 838 | config['mailhost'] = self.as_tuple(config['mailhost'])
|
|
0 commit comments