Skip to content

Extend Py3 Queue type hints#1885

Closed
Sterbic wants to merge 1 commit into
python:masterfrom
Sterbic:queue
Closed

Extend Py3 Queue type hints#1885
Sterbic wants to merge 1 commit into
python:masterfrom
Sterbic:queue

Conversation

@Sterbic

@Sterbic Sterbic commented Feb 15, 2018

Copy link
Copy Markdown
Contributor

No description provided.

@gvanrossum gvanrossum left a comment

Copy link
Copy Markdown
Member

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

Sterbic commented Feb 16, 2018

Copy link
Copy Markdown
Contributor Author

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

gvanrossum commented Feb 16, 2018 via email

Copy link
Copy Markdown
Member

@Sterbic

Sterbic commented Feb 17, 2018

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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