File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -948,6 +948,41 @@ This variant shows how you can e.g. apply configuration for particular loggers
948948machinery in the main process (even though the logging events are generated in
949949the worker processes) to direct the messages to the appropriate destinations.
950950
951+ Using concurrent.futures.ProcessPoolExecutor
952+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
953+
954+ If you want to use :class: `concurrent.futures.ProcessPoolExecutor ` to start
955+ your worker processes, you need to create the queue slightly differently.
956+ Instead of
957+
958+ .. code-block :: python
959+
960+ queue = multiprocessing.Queue(- 1 )
961+
962+ you should use
963+
964+ .. code-block :: python
965+
966+ queue = multiprocessing.Manager().Queue(- 1 ) # also works with the examples above
967+
968+ and you can then replace the worker creation from this::
969+
970+ workers = []
971+ for i in range(10):
972+ worker = multiprocessing.Process(target=worker_process,
973+ args=(queue, worker_configurer))
974+ workers.append(worker)
975+ worker.start()
976+ for w in workers:
977+ w.join()
978+
979+ to this (remembering to first import :mod: `concurrent.futures `)::
980+
981+ with concurrent.futures.ProcessPoolExecutor(max_workers=10) as executor:
982+ for i in range(10):
983+ executor.submit(worker_process, queue, worker_configurer)
984+
985+
951986Using file rotation
952987-------------------
953988
You can’t perform that action at this time.
0 commit comments