Skip to content

add timeout conex #48

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
njavilas opened this issue Mar 7, 2021 · 2 comments
Closed

add timeout conex #48

njavilas opened this issue Mar 7, 2021 · 2 comments

Comments

@njavilas
Copy link

njavilas commented Mar 7, 2021

hello I wanted to know how to implement a timeout for the connection
My application is simple but I need to know quickly if it is possible to connect with the remote pulse pulse = pulsectl.Pulse(server = 'ip_remote')

@mk-fg
Copy link
Owner

mk-fg commented Mar 8, 2021

Hi,

There indeed wasn't such option, but simple enough to add, so added in 96cfaec along with a couple tests for it.

With 21.3.4, something like this should work:

with pulsectl.Pulse('myclient', server='tcp4:my-remote-ip:my-port', connect=False) as pulse:
  pulse.connect(timeout=20) # will raise pulsectl.PulseError on timeout
  ...

(note that if attempt fails with timeout, you can retry pulse.connect() call there, if necessary)

Thanks for reporting.

@mk-fg mk-fg closed this as completed Mar 8, 2021
@mk-fg
Copy link
Owner

mk-fg commented Mar 8, 2021

connect() got an unexpected keyword argument 'timeout'

You seem to have removed the msg, so guess probably just forgot to update the module there.

with pulsectl.Pulse('myclient', server='tcp4:192.168.88.254:4713', connect=False) as pulse:

Btw, don't think you have to spell it out as tcp4:<host>:<port> - "man pulseaudio" says that prefix and port are optional, just used that notation in tests to make ipv4/ipv6 distinction clear.

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

2 participants