Skip to content

Commit 4a9665a

Browse files
committed
utilize SCRAPY_SETTINGS_MODULE env var
1 parent 8646c06 commit 4a9665a

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/apify/_actor.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import os
55
import sys
66
from datetime import timedelta
7-
from importlib.util import find_spec
87
from typing import TYPE_CHECKING, Any, Callable, Literal, TypeVar, cast, overload
98

109
from lazy_object_proxy import Proxy
@@ -267,15 +266,12 @@ async def finalize() -> None:
267266
await asyncio.wait_for(finalize(), cleanup_timeout.total_seconds())
268267
self._is_initialized = False
269268

270-
# Find out if Scrapy is installed.
271-
scrapy_installed = find_spec('scrapy') is not None
272-
273269
if is_running_in_ipython():
274270
self.log.debug(f'Not calling sys.exit({exit_code}) because Actor is running in IPython')
275271
elif os.getenv('PYTEST_CURRENT_TEST', default=False): # noqa: PLW1508
276272
self.log.debug(f'Not calling sys.exit({exit_code}) because Actor is running in an unit test')
277-
elif scrapy_installed:
278-
self.log.debug(f'Not calling sys.exit({exit_code}) because Actor is running in Scrapy')
273+
elif os.getenv('SCRAPY_SETTINGS_MODULE'):
274+
self.log.debug(f'Not calling sys.exit({exit_code}) because Actor is running with Scrapy')
279275
else:
280276
sys.exit(exit_code)
281277

0 commit comments

Comments
 (0)