004-async-password.py 637 B

1234567891011121314151617181920212223242526272829303132
  1. import asyncio
  2. import sys
  3. import pathlib
  4. test_file = pathlib.Path(__file__)
  5. project = test_file.parent.parent
  6. sys.path.append(str(project))
  7. import server_source as source
  8. from test import test
  9. async def printing():
  10. for count in range(20):
  11. print("Count: #" + str(count + 1))
  12. await asyncio.sleep(0.1)
  13. async def hashing():
  14. for count in range(10):
  15. result = await source.password.from_plain_text(
  16. "sample_password"
  17. )
  18. print("Hashed #" + str(count + 1) + " password")
  19. async def main():
  20. await asyncio.gather(
  21. hashing(),
  22. printing()
  23. )
  24. asyncio.run(main())