aardio_ multithreading in Python

1, import Python library in the main thread

  import py;

2, the main thread releases the GIL

  py.releaseThread();

3, call Python script (Python script py.lock must be called in, otherwise it will error)

  . A main thread calls: 

    py.lock(
      function(){
        test1 = py.import("test1");
        test1.run();
      }
    )

  . B sub-thread call:

    import py; // child thread needs to re-import the Python library

    py.lock( 
      function(){
        test2 = py.import("test2");
        test2.run();
      }
    )

Guess you like

Origin www.cnblogs.com/dabaicai0703/p/11221464.html