source: python/trunk/Demo/embed/loop.c

Last change on this file was 391, checked in by dmik, 11 years ago

python: Merge vendor 2.7.6 to trunk.

  • Property svn:eol-style set to native
File size: 740 bytes
RevLine 
[2]1/* Simple program that repeatedly calls Py_Initialize(), does something, and
2 then calls Py_Finalize(). This should help finding leaks related to
3 initialization. */
4
5#include "Python.h"
6
7main(int argc, char **argv)
8{
[391]9 int count = -1;
10 char *command;
[2]11
[391]12 if (argc < 2 || argc > 3) {
13 fprintf(stderr, "usage: loop <python-command> [count]\n");
14 exit(2);
15 }
16 command = argv[1];
[2]17
[391]18 if (argc == 3) {
19 count = atoi(argv[2]);
20 }
[2]21
[391]22 Py_SetProgramName(argv[0]);
[2]23
[391]24 /* uncomment this if you don't want to load site.py */
25 /* Py_NoSiteFlag = 1; */
[2]26
[391]27 while (count == -1 || --count >= 0 ) {
28 Py_Initialize();
29 PyRun_SimpleString(command);
30 Py_Finalize();
31 }
32 return 0;
[2]33}
Note: See TracBrowser for help on using the repository browser.