Skip to content

multiprocessing.Queue doesn't match Queue[all] for logging.handlers.QueueHandler #3804

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bcl opened this issue Aug 5, 2017 · 3 comments
Closed

Comments

@bcl
Copy link

bcl commented Aug 5, 2017

import logging.handlers
import multiprocessing as mp

def foo(queue: mp.Queue):
    handler = logging.handlers.QueueHandler(queue)

Returns the error:
tt.py:6: error: Argument 1 to "QueueHandler" has incompatible type "Queue"; expected Queue[Any]

@gvanrossum
Copy link
Member

This is a typeshed issue.

The Queue expected by logging.handlers.QueueHandler() is a queue.Queue. It seems the multiprocessing.Queue class emulates that (i.e. duck typing). We might fix this by adding queue.Queue as the base class of multiprocessing.Queue in the stubs for multiprocessing. It should probably become a generic class then (since queue.Queue is generic). Do you want to attempt that as a PR for typeshed?

@bcl
Copy link
Author

bcl commented Aug 6, 2017

Sure - python/typeshed#1525

@JelleZijlstra
Copy link
Member

Closing this since we can discuss on the typeshed issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants