- Notifications
You must be signed in to change notification settings - Fork 31.7k
/
Copy pathloop.c
33 lines (26 loc) · 740 Bytes
/
loop.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* Simple program that repeatedly calls Py_Initialize(), does something, and
then calls Py_Finalize(). This should help finding leaks related to
initialization. */
#include"Python.h"
main(intargc, char**argv)
{
intcount=-1;
char*command;
if (argc<2||argc>3) {
fprintf(stderr, "usage: loop <python-command> [count]\n");
exit(2);
}
command=argv[1];
if (argc==3) {
count=atoi(argv[2]);
}
Py_SetProgramName(argv[0]);
/* uncomment this if you don't want to load site.py */
/* Py_NoSiteFlag = 1; */
while (count==-1||--count >= 0 ) {
Py_Initialize();
PyRun_SimpleString(command);
Py_Finalize();
}
return0;
}