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

Inconsistent publish rate #69

Open
hasauino opened this issue May 5, 2021 · 0 comments
Open

Inconsistent publish rate #69

hasauino opened this issue May 5, 2021 · 0 comments

Comments

@hasauino
Copy link

hasauino commented May 5, 2021

I experience inconsistent data rate when publishing at relatively high frequency.
For example, if the subscription consists of a single integer field, broadcasted in a loop at a rate of 10 Hz, the client receives the integer values at a non-constant rate; for a second the data is received fast, for another data slows down.
What could be the reason?

Subscription:

class MySubscription(channels_graphql_ws.Subscription):

    number = graphene.Int()

    @staticmethod
    def subscribe(root, info):
        return ["all"]

    @staticmethod
    def publish(payload, info):
        return MySubscription(number=payload["number"])

Thread that broadcasts integer values:

class Core(threading.Thread):
    def run(self):
        i = 0
        while True:
            sleep(0.1)
            i += 1
            print("\n\n broadcasted.. {}\n\n".format(i))
            from .schema import MySubscription
            MySubscription.broadcast(group="all", payload={"number": i})

And the consumer:

class MyGraphqlWsConsumer(channels_graphql_ws.GraphqlWsConsumer):

    schema = graphql_schema
    
    async def on_connect(self, payload):
        print("New client connected!")
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