0

I have a program written in python (version 2.7.4) which has 3 threads.

One thread is processing some data and does some web service requests , the other (MONITOR THREAD) inserts the data in a database and the other is responsible to open a monitor a vpn connection.

In order to do that it uses the openvpn client (ubuntu linux). It does that by invoking

subprocess.Popen(openvpn_cmd)

the above command does a fork, as I understood, each time is executed.

This command is executed every hour. After 3-4 executions the following exception occurs:

OSError: [Errno 12] Cannot allocate memory

Is there any way to avoid this behavior?

gosom
  • 1,299
  • 3
  • 16
  • 35
  • related: [Python subprocess.Popen “OSError: \[Errno 12\] Cannot allocate memory”](http://stackoverflow.com/q/1367373/4279) – jfs May 23 '14 at 22:24
  • 1
    to workaround the issue, you could try to run `subprocess.Popen` loop from within a child process `multiprocessing.Process` instead of a thread. Start the child process before starting threads or allocating memory, other resources in the parent process. – jfs May 23 '14 at 22:31
  • @J.F. Sebastian This did the trick. – gosom May 24 '14 at 15:24

0 Answers0