Skip to content

[Bug] AdvancedSubscriber does not garbage collect on session.close() #624

@jeffective

Description

@jeffective

Describe the bug

This script hangs:

import zenoh
from zenoh.ext import declare_advanced_subscriber

class ManagedSession:

    def __init__(self):
        pass

    def __enter__(self):
        self.session = zenoh.open(config=zenoh.Config())
        self.subscriber = declare_advanced_subscriber(self.session, "test", self.sample_callback)
        return self
    
    def __exit__(self, exc_type, exc_val, exc_tb):
        # workaround is to call 
        # self.subscriber.undeclare()
        self.session.close()
    
    def sample_callback(self, sample):
        pass 


with ManagedSession() as session:
    pass

This script does not hang:

import zenoh

class ManagedSession:

    def __init__(self):
        pass

    def __enter__(self):
        self.session = zenoh.open(config=zenoh.Config())
        self.subscriber = self.session.declare_subscriber("test", self.sample_callback)
        return self
    
    def __exit__(self, exc_type, exc_val, exc_tb):
        self.session.close()
    
    def sample_callback(self, sample):
        pass 


with ManagedSession() as session:
    pass

To reproduce

See code examples above.

System info

eclipse-zenoh version 1.6.2 on x86-64 linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions