Staging
v0.5.1
swh:1:snp:635f4099902912592851108bcac178ff574f7c5f
Raw File
Tip revision: 09a7df8301bef5a5ac957371ae9e19c68acdca0a authored by Georg Brandl on 19 December 2010, 12:33:52 UTC
#3243 follow-up: remove debugging print and fix docs; data is a bytes object.
Tip revision: 09a7df8
loop.c
/* 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)
{
    int count = -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(L"loop");

    /* 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();
    }
    return 0;
}
back to top