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

Subscribe causes hang on program exit #142

Open
jun0 opened this issue Oct 17, 2022 · 0 comments
Open

Subscribe causes hang on program exit #142

jun0 opened this issue Oct 17, 2022 · 0 comments

Comments

@jun0
Copy link

jun0 commented Oct 17, 2022

When I subscribe to any channel and spend about >= 0.5s before calling unsubscribe_all() and stop, the program hangs at the end, requiring a keyboard interrupt to terminate. hanging_threads reports that Thread-Subscribe-0 is hung waiting for some request, but I'm not sure how to figure out what request it's waiting on (sorry, not very good with python).

Below is a small test demonstrating the problem, but in fact examples/native_threads/check.py also hangs. I'm running this on macOS Monterey 12.4 with Python 3.9.13, PubNub package 7.0.1 installed from pip.

publish_key = '...'
subscribe_key = '...'

from hanging_threads import start_monitoring
monitoring_thread = start_monitoring (seconds_frozen=5, test_interval=100)

import pubnub
from pubnub.pubnub import PNConfiguration, PubNub, SubscribeCallback
from pubnub.utils import PNStatusCategory

pnconfig = PNConfiguration()
pnconfig.publish_key = publish_key
pnconfig.subscribe_key = subscribe_key
pnconfig.uuid = 'some-uuid'
pubnub = PubNub (pnconfig)

pubnub.subscribe ().channels ('test-channel').execute ()

import time
time.sleep (0.5) # The length of sleep matters, apparently.
print ('done sleeping')

pubnub.unsubscribe_all ()
print ('unsubscribed')

pubnub.stop ()
print ('pubnub stopped')

# hangs here
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

1 participant