Keep the session alive until the browser page is closed by user. .. attention:: Since PyWebIO v1.4, in :ref:`server mode `, it's no need to call this function manually, PyWebIO will automatically hold the session for you when needed. The only case to use it
()
| 293 | |
| 294 | @chose_impl |
| 295 | def hold(): |
| 296 | """Keep the session alive until the browser page is closed by user. |
| 297 | |
| 298 | .. attention:: |
| 299 | |
| 300 | Since PyWebIO v1.4, in :ref:`server mode <server_mode>`, it's no need to call this function manually, |
| 301 | PyWebIO will automatically hold the session for you when needed. |
| 302 | The only case to use it is to prevent the application from exiting in script mode. |
| 303 | |
| 304 | In case you use the previous version of PyWebIO (we strongly recommend that you upgrade to the latest version), |
| 305 | here is the old document for ``hold()``: |
| 306 | |
| 307 | After the PyWebIO session closed, the functions that need communicate with the PyWebIO server |
| 308 | (such as the event callback of `put_buttons()` and download link of `put_file()`) will not work. |
| 309 | You can call the ``hold()`` function at the end of the task function to hold the session, |
| 310 | so that the event callback and download link will always be available before the browser page is closed by user. |
| 311 | |
| 312 | """ |
| 313 | while True: |
| 314 | try: |
| 315 | yield next_client_event() |
| 316 | except SessionException: |
| 317 | return |
| 318 | |
| 319 | |
| 320 | def download(name, content): |
no test coverage detected
searching dependent graphs…