Skip to content

Throttle backend activity when no clients connected #232

Closed Answered by bapowell
bapowell asked this question in Q&A
Discussion options

You must be logged in to vote

Regarding this discussion, the changes introduced in v1.1.0 work well. Thank you.
Here's an example demonstrating the functionality:

import asyncio
import logging

from nicegui import ui, app, Client
import nicegui.globals
from fastapi import Request

logging.basicConfig(level=logging.DEBUG)
webui_client_count = 0

ui.label('Hello')  # will be put on the auto-index page

@ui.page('/page1', title='Page #1')
def page1(request: Request, client: Client):
    logging.debug(f'page1(request={request}, client={client})')
    ui.label('Lifecycle testing - using client.on_connect|disconnect').classes('text-lg text-weight-bold')
    client.on_connect(lambda: logging.debug('page1: on_connect fired'))…

Replies: 7 comments 7 replies

Comment options

You must be logged in to vote
2 replies
@bapowell
Comment options

@falkoschindler
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@bapowell
Comment options

Comment options

You must be logged in to vote
4 replies
@canDry
Comment options

@rodja
Comment options

@canDry
Comment options

@rodja
Comment options

Answer selected by bapowell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants