Skip to content

Commit 4c83f40

Browse files
committed
scrapy
1 parent 8147b7c commit 4c83f40

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/apify/_actor.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,22 +1140,19 @@ async def create_proxy_configuration(
11401140
def _get_default_call_exit(self) -> bool:
11411141
"""Returns False for IPython, Pytest, and Scrapy environments, True otherwise."""
11421142
if is_running_in_ipython():
1143-
self.log.debug('Actor is running in IPython, setting default call exit to False.')
1143+
self.log.debug('Running in IPython, setting default `call_exit` to False.')
11441144
return False
11451145

1146+
# Check if running in Pytest by detecting the relevant environment variable.
11461147
if os.getenv('PYTEST_CURRENT_TEST'):
1147-
self.log.debug('Actor is running in Pytest, setting default call exit to False.')
1148+
self.log.debug('Running in Pytest, setting default `call_exit` to False.')
11481149
return False
11491150

1150-
if os.getenv('SCRAPY_SETTINGS_MODULE'):
1151-
self.log.debug('Actor is running in Scrapy, setting default call exit to False.')
1152-
return False
1153-
1154-
# Scrapy setting env var alone may not be sufficient; verify by attempting to import Scrapy.
1151+
# Check if running in Scrapy by attempting to import it.
11551152
with suppress(ImportError):
11561153
import scrapy # noqa: F401
11571154

1158-
self.log.debug('Actor is running in Scrapy, setting default call exit to False.')
1155+
self.log.debug('Running in Scrapy, setting default `call_exit` to False.')
11591156
return False
11601157

11611158
return True

0 commit comments

Comments
 (0)