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

[NotificationService] Cannot use one EmbeddedNotificationClient instance in multiple threads #351

Open
jiangxin369 opened this issue Jul 11, 2022 · 0 comments

Comments

@jiangxin369
Copy link
Contributor

Describe the bug

Cannot use one EmbeddedNotificationClient instance in multiple threads.

Your environment

Operating system

Database

Python version

To Reproduce

    def test_create_client_multiple_threads(self):
        import threading
        from notification_service.embedded_notification_client import EmbeddedNotificationClient
        from notification_service.event import Event, EventKey

        client = EmbeddedNotificationClient(server_uri="localhost:50052", namespace='default', sender='sender')

        def send_event():
            event = Event(event_key=EventKey('key1'), message='a')
            client.send_event(event)
            print(client.sequence_number)
        threads = []
        for i in range(100):
            thread = threading.Thread(target=send_event)
            threads.append(thread)
        for t in threads:
            t.start()
        for t in threads:
            t.join()

Expected behavior

100 events sent.

Actual behavior

less than 100 events sent.

Screenshots

Additional context

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