blob: 4a341fdf522134b660c003d27544d9d1414e1c9a [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{
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +00009 int count = -1;
10 char *command;
Guido van Rossum3559d1f2001-01-10 17:11:51 +000011
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000012 if (argc < 2 || argc > 3) {
13 fprintf(stderr, "usage: loop <python-command> [count]\n");
14 exit(2);
15 }
16 command = argv[1];
Guido van Rossum3559d1f2001-01-10 17:11:51 +000017
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000018 if (argc == 3) {
19 count = atoi(argv[2]);
20 }
Barry Warsaw0c63fe92001-01-23 16:42:01 +000021
Georg Brandlcea7e552010-08-01 18:56:30 +000022 Py_SetProgramName(L"loop");
Guido van Rossum3559d1f2001-01-10 17:11:51 +000023
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000024 /* uncomment this if you don't want to load site.py */
25 /* Py_NoSiteFlag = 1; */
Barry Warsaw0c63fe92001-01-23 16:42:01 +000026
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000027 while (count == -1 || --count >= 0 ) {
28 Py_Initialize();
29 PyRun_SimpleString(command);
30 Py_Finalize();
31 }
32 return 0;
Guido van Rossum3559d1f2001-01-10 17:11:51 +000033}