summaryrefslogtreecommitdiffstats
path: root/Demo/embed/loop.c
blob: ca89cb78cdc671b5085100520cd045fcec583424 (plain)
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
/* 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(int argc, char **argv)
{
	char *command;

	if (argc != 2) {
		fprintf(stderr, "usage: loop <python-command>\n");
		exit(2);
	}

	command = argv[1];

	Py_SetProgramName(argv[0]);

	while (1) {
		Py_Initialize();
		PyRun_SimpleString(command);
		Py_Finalize();
	}
	/*NOTREACHED*/
}