Skip to content

Subscribe causes hang on program exit #142

@jun0

Description

@jun0

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions