Skip to content
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

Force no timeout #157

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Force no timeout #157

wants to merge 1 commit into from

Conversation

ecarreras
Copy link
Member

@ecarreras ecarreras commented Jun 28, 2021

Put all socket operations in a context overriding de default timeout

import socket
from contextlib import contextmanager

@contextmanager
def NoTimeout():
    timeout = socket.getdefaulttimeout()
    try:
        socket.setdefaulttimeout(None)
        yield
    finally:
        socket.setdefaulttimeout(timeout)

Then we can use it as the following:

with NoTimeout():
    # All the connections inside this context won't have timeout
    pass

@ecarreras ecarreras self-assigned this Jun 28, 2021
@coveralls
Copy link

Pull Request Test Coverage Report for Build 339

  • 2 of 21 (9.52%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.006%) to 34.316%

Changes Missing Coverage Covered Lines Changed/Added Lines %
Koo/Rpc/Rpc.py 2 21 9.52%
Totals Coverage Status
Change from base Build 336: -0.006%
Covered Lines: 6135
Relevant Lines: 17878

💛 - Coveralls

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