|
4 | 4 | from typing import Any, Optional, Type, TypedDict, TypeVar, Union |
5 | 5 |
|
6 | 6 | import aiofiles |
7 | | -import ruyaml as yaml |
| 7 | +import yaml |
8 | 8 |
|
9 | 9 | from pyhilo.const import LOG |
10 | 10 |
|
@@ -42,7 +42,8 @@ class RegistrationDict(TypedDict, total=False): |
42 | 42 |
|
43 | 43 | class FirebaseDict(TypedDict): |
44 | 44 | fid: Optional[str] |
45 | | - name: Optional[str] # "projects/18450192328/installations/d7N8yHopRWOiTYCrnYLi8a" |
| 45 | + # "projects/18450192328/installations/d7N8yHopRWOiTYCrnYLi8a" |
| 46 | + name: Optional[str] |
46 | 47 | token: TokenDict |
47 | 48 |
|
48 | 49 |
|
@@ -108,9 +109,15 @@ async def set_state( |
108 | 109 | """ |
109 | 110 | async with lock: # note ic-dev21: on lock le fichier pour être sûr de finir la job |
110 | 111 | current_state = await get_state(state_yaml) or {} |
111 | | - merged_state: dict[str, Any] = {key: {**current_state.get(key, {}), **state}} # type: ignore |
| 112 | + merged_state: dict[str, Any] = { |
| 113 | + key: {**current_state.get(key, {}), **state} |
| 114 | + } # type: ignore |
112 | 115 | new_state: dict[str, Any] = {**current_state, **merged_state} |
113 | 116 | async with aiofiles.open(state_yaml, mode="w") as yaml_file: |
114 | 117 | LOG.debug("Saving state to yaml file") |
| 118 | + # TODO: Use asyncio.get_running_loop() and run_in_executor to write |
| 119 | + # to the file in a non blocking manner. Currently, the file writes |
| 120 | + # are properly async but the yaml dump is done synchroniously on the |
| 121 | + # main event loop. |
115 | 122 | content = yaml.dump(new_state) |
116 | 123 | await yaml_file.write(content) |
0 commit comments