Skip to content

Extend Py3 Queue type hints #1885

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
wants to merge 1 commit into from
Closed

Extend Py3 Queue type hints #1885

wants to merge 1 commit into from

Conversation

Sterbic
Copy link
Contributor

@Sterbic Sterbic commented Feb 15, 2018

No description provided.

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any of these documented at https://docs.python.org/3/library/queue.html#queue-objects -- perhaps it's better to leave them out? (UPDATE: In fact I'm sure of it.)

@Sterbic
Copy link
Contributor Author

Sterbic commented Feb 16, 2018

I only need all_tasks_done in production but added all the conditions since I was touching the file. See code snippet below:

async_queue = queue.Queue()
....
def unblock_queue_callback() -> None:
     with async_queue.all_tasks_done:
         async_queue.all_tasks_done.notify_all()

timeout = MyTimeout(60, callback=unblock_queue_callback)
        
# wait for all async logging jobs to finish
try:
    with timeout:
        async_queue.join()
except MyTimeoutError as ex:
    log()

Is the goal of the typeshed to be a backup documentation or to be as accurate at possible and minimise type errors?

@gvanrossum
Copy link
Member

gvanrossum commented Feb 16, 2018 via email

@Sterbic
Copy link
Contributor Author

Sterbic commented Feb 17, 2018

Fair enough, thanks for the explanation! So far I always viewed # type: ignore as something to be avoided at all costs.

In an ideal scenario, should those Queue attributes be private rather than public?

@gvanrossum
Copy link
Member

Yeah, it was probably a mistake (made 20 years ago) to have those attributes not start with _.

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

Successfully merging this pull request may close these issues.

2 participants