-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #241 from FabienArcellier/22-fix-fastapi-lifespan-…
…management-with-multiple-apps-at-once
- Loading branch information
Showing
12 changed files
with
478 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from pathlib import Path | ||
|
||
test_app_dir = Path(__file__).resolve().parent / 'testapp' | ||
test_multiapp_dir = Path(__file__).resolve().parent / 'testmultiapp' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import streamsync as ss | ||
|
||
# This is a placeholder to get you started or refresh your memory. | ||
# Delete it or adapt it as necessary. | ||
# Documentation is available at https://streamsync.cloud | ||
|
||
# Shows in the log when the app starts | ||
print("Hello world!") | ||
|
||
# Its name starts with _, so this function won't be exposed | ||
def _update_message(state): | ||
is_even = state["counter"] % 2 == 0 | ||
message = ("+Even" if is_even else "-Odd") | ||
state["message"] = message | ||
|
||
def decrement(state): | ||
state["counter"] -= 1 | ||
_update_message(state) | ||
|
||
def increment(state): | ||
state["counter"] += 1 | ||
# Shows in the log when the event handler is run | ||
print(f"The counter has been incremented.") | ||
_update_message(state) | ||
|
||
# Initialise the state | ||
|
||
# "_my_private_element" won't be serialised or sent to the frontend, | ||
# because it starts with an underscore | ||
|
||
initial_state = ss.init_state({ | ||
"my_app": { | ||
"title": "My App 1" | ||
}, | ||
"_my_private_element": 1337, | ||
"message": None, | ||
"counter": 26, | ||
}) | ||
|
||
_update_message(initial_state) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
{ | ||
"metadata": { | ||
"streamsync_version": "0.1.4" | ||
}, | ||
"components": { | ||
"root": { | ||
"id": "root", | ||
"type": "root", | ||
"content": { | ||
"appName": "My App 1" | ||
}, | ||
"parentId": null, | ||
"position": 0, | ||
"handlers": {}, | ||
"visible": true | ||
}, | ||
"c0f99a9e-5004-4e75-a6c6-36f17490b134": { | ||
"id": "c0f99a9e-5004-4e75-a6c6-36f17490b134", | ||
"type": "page", | ||
"content": { | ||
"pageMode": "compact", | ||
"emptinessColor": "#e9eef1" | ||
}, | ||
"parentId": "root", | ||
"position": 0, | ||
"handlers": {}, | ||
"visible": true | ||
}, | ||
"bebc5fe9-63a7-46a7-b0fa-62303555cfaf": { | ||
"id": "bebc5fe9-63a7-46a7-b0fa-62303555cfaf", | ||
"type": "header", | ||
"content": { | ||
"text": "@{my_app.title}" | ||
}, | ||
"parentId": "c0f99a9e-5004-4e75-a6c6-36f17490b134", | ||
"position": 0, | ||
"handlers": {}, | ||
"visible": true | ||
}, | ||
"28d3885b-0fb8-4d41-97c6-978540015431": { | ||
"id": "28d3885b-0fb8-4d41-97c6-978540015431", | ||
"type": "section", | ||
"content": { | ||
"title": "", | ||
"snapMode": "no", | ||
"containerShadow": "0px 4px 11px -12px #000000" | ||
}, | ||
"parentId": "c0f99a9e-5004-4e75-a6c6-36f17490b134", | ||
"position": 1, | ||
"handlers": {}, | ||
"visible": true | ||
}, | ||
"9556c0e3-8584-4ac9-903f-908a775a33ec": { | ||
"id": "9556c0e3-8584-4ac9-903f-908a775a33ec", | ||
"type": "button", | ||
"content": { | ||
"text": " Increment", | ||
"icon": "arrow-up" | ||
}, | ||
"parentId": "0d05bc9f-1655-4d0b-bc9b-c2f4c71a5117", | ||
"position": 1, | ||
"handlers": { | ||
"click": "increment" | ||
}, | ||
"visible": true | ||
}, | ||
"51d1554e-1b88-461c-9353-1419cba0053a": { | ||
"id": "51d1554e-1b88-461c-9353-1419cba0053a", | ||
"type": "button", | ||
"content": { | ||
"text": "Decrement", | ||
"icon": "arrow-down" | ||
}, | ||
"parentId": "0d05bc9f-1655-4d0b-bc9b-c2f4c71a5117", | ||
"position": 0, | ||
"handlers": { | ||
"click": "decrement" | ||
}, | ||
"visible": true | ||
}, | ||
"0d05bc9f-1655-4d0b-bc9b-c2f4c71a5117": { | ||
"id": "0d05bc9f-1655-4d0b-bc9b-c2f4c71a5117", | ||
"type": "horizontalstack", | ||
"content": { | ||
"alignment": "left" | ||
}, | ||
"parentId": "f3777e75-3659-4d44-8ef7-aeec0d06855b", | ||
"position": 0, | ||
"handlers": {}, | ||
"visible": true | ||
}, | ||
"172a14df-f73a-44fa-8fb1-e8648e7d32d2": { | ||
"id": "172a14df-f73a-44fa-8fb1-e8648e7d32d2", | ||
"type": "metric", | ||
"content": { | ||
"metricValue": "@{counter}", | ||
"note": "@{message}", | ||
"name": "Counter" | ||
}, | ||
"parentId": "c2519671-9ce7-44e7-ba4e-b0efda9cb20e", | ||
"position": 0, | ||
"handlers": {}, | ||
"visible": true | ||
}, | ||
"d4a5e62c-c6fe-49c4-80d4-33862af8727d": { | ||
"id": "d4a5e62c-c6fe-49c4-80d4-33862af8727d", | ||
"type": "columns", | ||
"content": {}, | ||
"parentId": "28d3885b-0fb8-4d41-97c6-978540015431", | ||
"position": 0, | ||
"handlers": {}, | ||
"visible": true | ||
}, | ||
"f3777e75-3659-4d44-8ef7-aeec0d06855b": { | ||
"id": "f3777e75-3659-4d44-8ef7-aeec0d06855b", | ||
"type": "column", | ||
"content": { | ||
"title": "", | ||
"width": "1", | ||
"verticalAlignment": "center", | ||
"horizontalAlignment": "center" | ||
}, | ||
"parentId": "d4a5e62c-c6fe-49c4-80d4-33862af8727d", | ||
"position": 2, | ||
"handlers": {}, | ||
"visible": true | ||
}, | ||
"c2519671-9ce7-44e7-ba4e-b0efda9cb20e": { | ||
"id": "c2519671-9ce7-44e7-ba4e-b0efda9cb20e", | ||
"type": "column", | ||
"content": { | ||
"width": "1" | ||
}, | ||
"parentId": "d4a5e62c-c6fe-49c4-80d4-33862af8727d", | ||
"position": 0, | ||
"handlers": {}, | ||
"visible": true | ||
}, | ||
"d4a71819-7444-4083-a1c7-7995452a7abf": { | ||
"id": "d4a71819-7444-4083-a1c7-7995452a7abf", | ||
"type": "separator", | ||
"content": {}, | ||
"parentId": "d4a5e62c-c6fe-49c4-80d4-33862af8727d", | ||
"position": 1, | ||
"handlers": {}, | ||
"visible": true | ||
} | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import streamsync as ss | ||
|
||
# This is a placeholder to get you started or refresh your memory. | ||
# Delete it or adapt it as necessary. | ||
# Documentation is available at https://streamsync.cloud | ||
|
||
# Shows in the log when the app starts | ||
print("Hello world!") | ||
|
||
# Its name starts with _, so this function won't be exposed | ||
def _update_message(state): | ||
is_even = state["counter"] % 2 == 0 | ||
message = ("+Even" if is_even else "-Odd") | ||
state["message"] = message | ||
|
||
def decrement(state): | ||
state["counter"] -= 1 | ||
_update_message(state) | ||
|
||
def increment(state): | ||
state["counter"] += 1 | ||
# Shows in the log when the event handler is run | ||
print(f"The counter has been incremented.") | ||
_update_message(state) | ||
|
||
# Initialise the state | ||
|
||
# "_my_private_element" won't be serialised or sent to the frontend, | ||
# because it starts with an underscore | ||
|
||
initial_state = ss.init_state({ | ||
"my_app": { | ||
"title": "My App 2" | ||
}, | ||
"_my_private_element": 1337, | ||
"message": None, | ||
"counter": 26, | ||
}) | ||
|
||
_update_message(initial_state) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.