fix: add a check thread before set `add_signal_handler` by Mantisus · Pull Request #1068 · apify/crawlee-python

The problem is reproduces in GCP Cloud Functions. Since under the hood they use Flask run via guvicorn

        File "/crawlee/crawlers/_basic/_basic_crawler.py", line 539, in run
          asyncio.get_running_loop().add_signal_handler(signal.SIGINT, sigint_handler)
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/asyncio/unix_events.py", line 109, in add_signal_handler
          raise RuntimeError(str(exc))
      RuntimeError: set_wakeup_fd only works in main thread of the main interpreter