blob: d5af82986d66f8dae782d00a9199c664e3b90533 [file] [log] [blame]
Guido van Rossum3559d1f2001-01-10 17:11:51 +00001/* 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{
Barry Warsaw0c63fe92001-01-23 16:42:01 +00009 int count = -1;
Guido van Rossum3559d1f2001-01-10 17:11:51 +000010 char *command;
11
Barry Warsaw0c63fe92001-01-23 16:42:01 +000012 if (argc < 2 || argc > 3) {
13 fprintf(stderr, "usage: loop <python-command> [count]\n");
Guido van Rossum3559d1f2001-01-10 17:11:51 +000014 exit(2);
15 }
Guido van Rossum3559d1f2001-01-10 17:11:51 +000016 command = argv[1];
17
Barry Warsaw0c63fe92001-01-23 16:42:01 +000018 if (argc == 3) {
19 count = atoi(argv[2]);
20 }
21
Guido van Rossum3559d1f2001-01-10 17:11:51 +000022 Py_SetProgramName(argv[0]);
23
Barry Warsaw0c63fe92001-01-23 16:42:01 +000024 /* uncomment this if you don't want to load site.py */
25 /* Py_NoSiteFlag = 1; */
26
27 while (count == -1 || --count >= 0 ) {
Guido van Rossum3559d1f2001-01-10 17:11:51 +000028 Py_Initialize();
29 PyRun_SimpleString(command);
30 Py_Finalize();
31 }
Barry Warsaw0c63fe92001-01-23 16:42:01 +000032 return 0;
Guido van Rossum3559d1f2001-01-10 17:11:51 +000033}