startSnowflake.py 664 B

12345678910111213141516171819202122232425262728293031323334
  1. import os
  2. from threading import Thread
  3. import snowflake.client
  4. import time
  5. def get_guid():
  6. while(True):
  7. try:
  8. return snowflake.client.get_guid()
  9. except Exception as e:
  10. pass
  11. def startSnowflake(port=None,worker=None):
  12. _cmd = "snowflake_start_server"
  13. if worker is not None:
  14. _cmd += " --worker=%d"%worker
  15. if port is not None:
  16. _cmd += " --port=%d"%port
  17. os.system(_cmd)
  18. thread_startSnowflake = Thread(target=startSnowflake)
  19. thread_startSnowflake.start()
  20. time.sleep(2)
  21. if __name__=="__main__":
  22. thread_startSnowflake = Thread(target=startSnowflake)
  23. thread_startSnowflake.start()