Sign up for Apify Platform here
Star Crawlee on GitHub
Star Crawlee for Python on GitHub
Apify and Crawlee Official Forum
New post
View all posts
Related posts
Did this answer your question?
π
π
π
Powered by
Hall
Inactive
Updated 7 months ago
0
Follow
Using the Actor instance across multiple files
Using the Actor instance across multiple files
Inactive
0
Follow
D
Deepak Antony
7 months ago
Β·
Hi, how can i use the same actor instance across multiple functions defined in seperate files?
for example, if I define an Actor in the main.py file as:
async with Actor:
(some code)
How do i use Actor.log.info() in another function that is called from the main script?
Would appreciate any help in this.
A
M
D
3 comments
Share
Open in Discord
A
ApifyBot
7 months ago
just advanced to level 1! Thanks for your contributions! π
M
Mantisus
7 months ago
Hey
just use it everywhere.
Plain Text
Copy
from apify import Actor def my_function(): Actor.log.info()
Think of it as a singleton
After calling
Plain Text
Copy
async with Actor: (some code)
In all imports you will refer to this particular Actor
D
Deepak Antony
7 months ago
This is what I was wondering. As I checked the instance id across different files, they were all the same.
Thank you for confirming
Add a reply
Sign up and join the conversation on Discord
Join on Discord