diff options
author | Barry Warsaw <barry@python.org> | 2001-01-23 16:42:01 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2001-01-23 16:42:01 (GMT) |
commit | 0c63fe9b54379e635b54fea4060b01e0feddb7fb (patch) | |
tree | 0543dc5adfb408518f668684c17d9e12025eb7a1 /Demo/embed/loop.c | |
parent | 7d23b59e3433cfebb917876a9a1a13b622a850c1 (diff) | |
download | cpython-0c63fe9b54379e635b54fea4060b01e0feddb7fb.zip cpython-0c63fe9b54379e635b54fea4060b01e0feddb7fb.tar.gz cpython-0c63fe9b54379e635b54fea4060b01e0feddb7fb.tar.bz2 |
Slight reworking to make it more useful for debugging
Py_Initialize()/Py_Finalize() loop leaks.
- allow an optional 3rd argument which is the loop count. -1 means
infloop (the default).
- Add a setting of Py_NoSiteFlag=1, but leave it commented out by
default.
Diffstat (limited to 'Demo/embed/loop.c')
-rw-r--r-- | Demo/embed/loop.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Demo/embed/loop.c b/Demo/embed/loop.c index ca89cb7..d5af829 100644 --- a/Demo/embed/loop.c +++ b/Demo/embed/loop.c @@ -6,21 +6,28 @@ main(int argc, char **argv) { + int count = -1; char *command; - if (argc != 2) { - fprintf(stderr, "usage: loop <python-command>\n"); + 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(argv[0]); - while (1) { + /* 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(); } - /*NOTREACHED*/ + return 0; } |