1

I wanna use Python 2.7 to execute an async while loop.

while True:
    #getting real-time data from calling the API
    #make some calculations based on the response return by API 15 min after

Could anyone help me with that? Many thanks.

Jack Fei
  • 11
  • 1
  • Related: https://stackoverflow.com/questions/1239035/asynchronous-method-call-in-python – Aimery Jun 11 '18 at 13:35
  • 1
    Also, why Python 2.7? Per the [official wiki](https://wiki.python.org/moin/Python2orPython3): *Python 2.x is legacy, Python 3.x is the present and future of the language.* – Aimery Jun 11 '18 at 13:37
  • Thanks. But I do not want the second execution to block the while loop. I mean, the first statement does not need to wait until the 2nd statement finishes. – Jack Fei Jun 12 '18 at 05:48
  • You can still use `threading` ([documentation](https://docs.python.org/3/library/threading.html#module-threading)), just don't use `join()`. Same for `multiprocessing` ([documentation](https://docs.python.org/3/library/multiprocessing.html)): create a `Process` object, don't call `join()`. – Aimery Jun 12 '18 at 07:51

0 Answers0