-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdemo.py
37 lines (27 loc) · 1.03 KB
/
demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import asyncio
import uuid
from confidence.confidence import Confidence
async def get_flag():
root = Confidence("API CLIENT", timeout_ms=100)
random_uuid = uuid.uuid4()
uuid_string = str(random_uuid)
confidence = root.with_context({"targeting_key": uuid_string})
#confidence.with_context({"app": "python"}).track("navigate", {})
#print("Tracked navigate event")
details = confidence.resolve_string_details("hawkflag.color", "default")
print(f"Flag value: {details.value}")
print(f"Flag reason: {details.reason}")
print(f"Flag error code: {details.error_code}")
print(f"Flag error message: {details.error_message}")
# Another asynchronous function that calls the first one
async def main():
await get_flag()
print("Finished calling get_flag")
await asyncio.sleep(1)
print("Finished sleeping for 1 seconds")
def sync_main():
print("Running main asynchronously")
# Run the main function using asyncio.run (Python 3.7+)
if __name__ == "__main__":
asyncio.run(main())
sync_main()