0

I'm working with a python library (arcpy) that has a long import time (1-2min) due checks done against a license server. This makes debug sessions extremely slow when I'm re-running code multiple times.

Is there a way I can import the library to python process #1, and keep that process always live, then use that library from python process #2?

Something like:

Script 1 Script 2
while True: from script 1 import arcpy
import arcpy

Have not tried approaches as I'm not even sure if something like this is feasible...Is this possible?

Aloha Ray
  • 13
  • 4

1 Answers1

0

You could try using multiprocessing, a simple example in this answer. Of course, you would have to set up the Listener to use the library in question. You could use exec() to make the listener run whatever code you send it and send back the response (in python3, result must be global or you need to pass exec a dictionary for local variables as explained in this answer).

Client:

conn.send("result=15")
print(conn.recv()) #15

Server:

var cmd = conn.recv()
exec(cmd)
conn.send(result)