annotate Modules/threadmodule.c @ 9383:2b34461ba4a3 legacy-trunk

PyMapping_SetItemString() returns int, not an object.
author Guido van Rossum <guido@python.org>
date Fri, 16 Oct 1998 17:43:53 +0000
parents a6cff9c290e5
children 38023a425e48
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 /***********************************************************
2061
172ba04a5191 Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents: 2055
diff changeset
2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
172ba04a5191 Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents: 2055
diff changeset
3 The Netherlands.
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
4
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 All Rights Reserved
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
6
4503
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 2568
diff changeset
7 Permission to use, copy, modify, and distribute this software and its
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 2568
diff changeset
8 documentation for any purpose and without fee is hereby granted,
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 provided that the above copyright notice appear in all copies and that
4503
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 2568
diff changeset
10 both that copyright notice and this permission notice appear in
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 supporting documentation, and that the names of Stichting Mathematisch
4503
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 2568
diff changeset
12 Centrum or CWI or Corporation for National Research Initiatives or
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 2568
diff changeset
13 CNRI not be used in advertising or publicity pertaining to
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 2568
diff changeset
14 distribution of the software without specific, written prior
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 2568
diff changeset
15 permission.
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
16
4503
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 2568
diff changeset
17 While CWI is the initial source for this software, a modified version
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 2568
diff changeset
18 is made available by the Corporation for National Research Initiatives
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 2568
diff changeset
19 (CNRI) at the Internet address ftp://ftp.python.org.
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 2568
diff changeset
20
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 2568
diff changeset
21 STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 2568
diff changeset
22 REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 2568
diff changeset
23 MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 2568
diff changeset
24 CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 2568
diff changeset
25 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 2568
diff changeset
26 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 2568
diff changeset
27 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 2568
diff changeset
28 PERFORMANCE OF THIS SOFTWARE.
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
29
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 ******************************************************************/
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
31
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
32 /* Thread module */
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 /* Interface to Sjoerd's portable C thread library */
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
34
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
35 #include "Python.h"
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
36
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
37 #ifndef WITH_THREAD
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
38 #error "Error! The rest of Python is not compiled with thread support."
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
39 #error "Rerun configure, adding a --with-thread option."
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
40 #error "Then run `make clean' followed by `make'."
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
41 #endif
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
42
9203
07dae6fdae79 Renamed thread.h to pythread.h.
Guido van Rossum <guido@python.org>
parents: 8823
diff changeset
43 #include "pythread.h"
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
44
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
45 static PyObject *ThreadError;
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
46
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
47
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
48 /* Lock objects */
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
49
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 typedef struct {
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
51 PyObject_HEAD
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
52 type_lock lock_lock;
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
53 } lockobject;
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
54
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
55 staticforward PyTypeObject Locktype;
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
56
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
57 static lockobject *
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
58 newlockobject()
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
59 {
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
60 lockobject *self;
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
61 self = PyObject_NEW(lockobject, &Locktype);
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
62 if (self == NULL)
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
63 return NULL;
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
64 self->lock_lock = allocate_lock();
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
65 if (self->lock_lock == NULL) {
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
66 PyMem_DEL(self);
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
67 self = NULL;
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
68 PyErr_SetString(ThreadError, "can't allocate lock");
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
69 }
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
70 return self;
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
71 }
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
72
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
73 static void
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
74 lock_dealloc(self)
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
75 lockobject *self;
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
76 {
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
77 /* Unlock the lock so it's safe to free it */
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
78 acquire_lock(self->lock_lock, 0);
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
79 release_lock(self->lock_lock);
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
80
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
81 free_lock(self->lock_lock);
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
82 PyMem_DEL(self);
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
83 }
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
84
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
85 static PyObject *
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
86 lock_acquire_lock(self, args)
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
87 lockobject *self;
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
88 PyObject *args;
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
89 {
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
90 int i;
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
91
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
92 if (args != NULL) {
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
93 if (!PyArg_Parse(args, "i", &i))
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
94 return NULL;
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
95 }
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
96 else
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
97 i = 1;
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
98
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
99 Py_BEGIN_ALLOW_THREADS
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
100 i = acquire_lock(self->lock_lock, i);
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
101 Py_END_ALLOW_THREADS
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
102
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
103 if (args == NULL) {
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
104 Py_INCREF(Py_None);
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
105 return Py_None;
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
106 }
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
107 else
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
108 return PyInt_FromLong((long)i);
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
109 }
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
110
8562
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
111 static char acquire_doc[] =
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
112 "acquire([wait]) -> None or Boolean\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
113 (acquire_lock() is an obsolete synonym)\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
114 \n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
115 Lock the lock. Without argument, this blocks if the lock is already\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
116 locked (even by the same thread), waiting for another thread to release\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
117 the lock, and return None when the lock is acquired.\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
118 With a Boolean argument, this will only block if the argument is true,\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
119 and the return value reflects whether the lock is acquired.\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
120 The blocking operation is not interruptible.";
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
121
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
122 static PyObject *
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
123 lock_release_lock(self, args)
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
124 lockobject *self;
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
125 PyObject *args;
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
126 {
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
127 if (!PyArg_NoArgs(args))
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
128 return NULL;
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
129
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
130 /* Sanity check: the lock must be locked */
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
131 if (acquire_lock(self->lock_lock, 0)) {
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
132 release_lock(self->lock_lock);
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
133 PyErr_SetString(ThreadError, "release unlocked lock");
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
134 return NULL;
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
135 }
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
136
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
137 release_lock(self->lock_lock);
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
138 Py_INCREF(Py_None);
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
139 return Py_None;
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
140 }
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
141
8562
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
142 static char release_doc[] =
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
143 "release()\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
144 (release_lock() is an obsolete synonym)\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
145 \n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
146 Release the lock, allowing another thread that is blocked waiting for\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
147 the lock to acquire the lock. The lock must be in the locked state,\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
148 but it needn't be locked by the same thread that unlocks it.";
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
149
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
150 static PyObject *
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
151 lock_locked_lock(self, args)
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
152 lockobject *self;
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
153 PyObject *args;
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
154 {
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
155 if (!PyArg_NoArgs(args))
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
156 return NULL;
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
157
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
158 if (acquire_lock(self->lock_lock, 0)) {
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
159 release_lock(self->lock_lock);
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
160 return PyInt_FromLong(0L);
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
161 }
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
162 return PyInt_FromLong(1L);
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
163 }
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
164
8562
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
165 static char locked_doc[] =
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
166 "locked() -> Boolean\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
167 (locked_lock() is an obsolete synonym)\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
168 \n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
169 Return whether the lock is in the locked state.";
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
170
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
171 static PyMethodDef lock_methods[] = {
8562
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
172 {"acquire_lock", (PyCFunction)lock_acquire_lock, 0, acquire_doc},
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
173 {"acquire", (PyCFunction)lock_acquire_lock, 0, acquire_doc},
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
174 {"release_lock", (PyCFunction)lock_release_lock, 0, release_doc},
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
175 {"release", (PyCFunction)lock_release_lock, 0, release_doc},
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
176 {"locked_lock", (PyCFunction)lock_locked_lock, 0, locked_doc},
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
177 {"locked", (PyCFunction)lock_locked_lock, 0, locked_doc},
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
178 {NULL, NULL} /* sentinel */
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
179 };
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
180
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
181 static PyObject *
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
182 lock_getattr(self, name)
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
183 lockobject *self;
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
184 char *name;
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
185 {
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
186 return Py_FindMethod(lock_methods, (PyObject *)self, name);
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
187 }
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
188
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
189 static PyTypeObject Locktype = {
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
190 PyObject_HEAD_INIT(&PyType_Type)
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
191 0, /*ob_size*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
192 "lock", /*tp_name*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
193 sizeof(lockobject), /*tp_size*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
194 0, /*tp_itemsize*/
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
195 /* methods */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
196 (destructor)lock_dealloc, /*tp_dealloc*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
197 0, /*tp_print*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
198 (getattrfunc)lock_getattr, /*tp_getattr*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
199 0, /*tp_setattr*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
200 0, /*tp_compare*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
201 0, /*tp_repr*/
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
202 };
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
203
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
204
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
205 /* Module functions */
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
206
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
207 struct bootstate {
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
208 PyInterpreterState *interp;
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
209 PyObject *func;
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
210 PyObject *args;
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
211 PyObject *keyw;
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
212 };
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
213
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
214 static void
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
215 t_bootstrap(boot_raw)
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
216 void *boot_raw;
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
217 {
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
218 struct bootstate *boot = (struct bootstate *) boot_raw;
5847
ff9c0110079b Use the new functions PyEval_AcquireThread() and
Guido van Rossum <guido@python.org>
parents: 5405
diff changeset
219 PyThreadState *tstate;
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
220 PyObject *res;
961
a31e07847063 New thread.c from Sjoerd, supports _exit_prog(). Use this in goaway()
Guido van Rossum <guido@python.org>
parents: 926
diff changeset
221
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
222 tstate = PyThreadState_New(boot->interp);
5847
ff9c0110079b Use the new functions PyEval_AcquireThread() and
Guido van Rossum <guido@python.org>
parents: 5405
diff changeset
223 PyEval_AcquireThread(tstate);
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
224 res = PyEval_CallObjectWithKeywords(
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
225 boot->func, boot->args, boot->keyw);
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
226 Py_DECREF(boot->func);
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
227 Py_DECREF(boot->args);
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
228 Py_XDECREF(boot->keyw);
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
229 PyMem_DEL(boot_raw);
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
230 if (res == NULL) {
8433
7cdff8aa8318 t_bootstrap(): Use PyErr_ExceptionMatches(...) instead of PyErr_Occurred(...).
Fred Drake <fdrake@acm.org>
parents: 7211
diff changeset
231 if (PyErr_ExceptionMatches(PyExc_SystemExit))
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
232 PyErr_Clear();
2568
2c61786327cf implement exit_thread through SystemExit exception
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
233 else {
2c61786327cf implement exit_thread through SystemExit exception
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
234 fprintf(stderr, "Unhandled exception in thread:\n");
7211
c764217ae6eb Don't store the exception info from an unhandled exception in a thread
Guido van Rossum <guido@python.org>
parents: 6367
diff changeset
235 PyErr_PrintEx(0);
2568
2c61786327cf implement exit_thread through SystemExit exception
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
236 }
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
237 }
2055
cf31eab6ab5a Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
238 else
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
239 Py_DECREF(res);
5927
63bc9289ab28 Oops, one more checkin. Use the new tstate/interp interface.
Guido van Rossum <guido@python.org>
parents: 5847
diff changeset
240 PyThreadState_Clear(tstate);
5847
ff9c0110079b Use the new functions PyEval_AcquireThread() and
Guido van Rossum <guido@python.org>
parents: 5405
diff changeset
241 PyEval_ReleaseThread(tstate);
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
242 PyThreadState_Delete(tstate);
8823
f2a4a2b60860 Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents: 8567
diff changeset
243 #ifdef __BEOS__
f2a4a2b60860 Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents: 8567
diff changeset
244 /* Dunno if this will cause problems with other ports; the BeOS thread
f2a4a2b60860 Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents: 8567
diff changeset
245 * support features only 100% renamed functions. [cjh]
f2a4a2b60860 Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents: 8567
diff changeset
246 */
f2a4a2b60860 Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents: 8567
diff changeset
247 PyThread_exit_thread();
f2a4a2b60860 Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents: 8567
diff changeset
248 #else
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
249 exit_thread();
8823
f2a4a2b60860 Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents: 8567
diff changeset
250 #endif
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
251 }
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
252
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
253 static PyObject *
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
254 thread_start_new_thread(self, fargs)
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
255 PyObject *self; /* Not used */
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
256 PyObject *fargs;
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
257 {
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
258 PyObject *func, *args = NULL, *keyw = NULL;
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
259 struct bootstate *boot;
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
260
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
261 if (!PyArg_ParseTuple(fargs, "OO|O", &func, &args, &keyw))
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
262 return NULL;
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
263 if (!PyCallable_Check(func)) {
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
264 PyErr_SetString(PyExc_TypeError,
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
265 "first arg must be callable");
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
266 return NULL;
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
267 }
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
268 if (!PyTuple_Check(args)) {
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
269 PyErr_SetString(PyExc_TypeError,
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
270 "optional 2nd arg must be a tuple");
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
271 return NULL;
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
272 }
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
273 if (keyw != NULL && !PyDict_Check(keyw)) {
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
274 PyErr_SetString(PyExc_TypeError,
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
275 "optional 3rd arg must be a dictionary");
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
276 return NULL;
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
277 }
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
278 boot = PyMem_NEW(struct bootstate, 1);
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
279 if (boot == NULL)
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
280 return PyErr_NoMemory();
5927
63bc9289ab28 Oops, one more checkin. Use the new tstate/interp interface.
Guido van Rossum <guido@python.org>
parents: 5847
diff changeset
281 boot->interp = PyThreadState_Get()->interp;
5405
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
282 boot->func = func;
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
283 boot->args = args;
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
284 boot->keyw = keyw;
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
285 Py_INCREF(func);
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
286 Py_INCREF(args);
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
287 Py_XINCREF(keyw);
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
288 PyEval_InitThreads(); /* Start the interpreter's thread-awareness */
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
289 if (!start_new_thread(t_bootstrap, (void*) boot)) {
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
290 PyErr_SetString(ThreadError, "can't start new thread\n");
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
291 Py_DECREF(func);
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
292 Py_DECREF(args);
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
293 Py_XDECREF(keyw);
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
294 PyMem_DEL(boot);
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
295 return NULL;
b7871ca930ad Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents: 4944
diff changeset
296 }
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
297 Py_INCREF(Py_None);
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
298 return Py_None;
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
299 }
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
300
8562
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
301 static char start_new_doc[] =
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
302 "start_new_thread(functon, args[, kwargs])\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
303 (start_new() is an obsolete synonym)\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
304 \n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
305 Start a new thread. The thread will call the function with positional\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
306 arguments from the tuple args and keyword arguments taken from the optional\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
307 dictionary kwargs. The thread exits when the function returns; the return\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
308 value is ignored. The thread will also exit when the function raises an\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
309 unhandled exception; a stack trace will be printed unless the exception is\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
310 SystemExit.";
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
311
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
312 static PyObject *
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
313 thread_exit_thread(self, args)
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
314 PyObject *self; /* Not used */
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
315 PyObject *args;
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
316 {
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
317 if (!PyArg_NoArgs(args))
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
318 return NULL;
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
319 PyErr_SetNone(PyExc_SystemExit);
2568
2c61786327cf implement exit_thread through SystemExit exception
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
320 return NULL;
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
321 }
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
322
8562
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
323 static char exit_doc[] =
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
324 "exit()\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
325 (exit_thread() is an obsolete synonym)\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
326 \n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
327 This is synonymous to ``raise SystemExit''. It will cause the current\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
328 thread to exit silently unless the exception is caught.";
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
329
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
330 #ifndef NO_EXIT_PROG
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
331 static PyObject *
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
332 thread_exit_prog(self, args)
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
333 PyObject *self; /* Not used */
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
334 PyObject *args;
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
335 {
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
336 int sts;
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
337 if (!PyArg_Parse(args, "i", &sts))
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
338 return NULL;
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
339 Py_Exit(sts); /* Calls exit_prog(sts) or _exit_prog(sts) */
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
340 for (;;) { } /* Should not be reached */
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
341 }
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
342 #endif
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
343
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
344 static PyObject *
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
345 thread_allocate_lock(self, args)
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
346 PyObject *self; /* Not used */
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
347 PyObject *args;
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
348 {
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
349 if (!PyArg_NoArgs(args))
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
350 return NULL;
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
351 return (PyObject *) newlockobject();
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
352 }
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
353
8562
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
354 static char allocate_doc[] =
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
355 "allocate_lock() -> lock object\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
356 (allocate() is an obsolete synonym)\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
357 \n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
358 Create a new lock object. See LockType.__doc__ for information about locks.";
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
359
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
360 static PyObject *
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
361 thread_get_ident(self, args)
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
362 PyObject *self; /* Not used */
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
363 PyObject *args;
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
364 {
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
365 long ident;
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
366 if (!PyArg_NoArgs(args))
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
367 return NULL;
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
368 ident = get_thread_ident();
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
369 if (ident == -1) {
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
370 PyErr_SetString(ThreadError, "no current thread ident");
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
371 return NULL;
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
372 }
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
373 return PyInt_FromLong(ident);
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
374 }
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
375
8562
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
376 static char get_ident_doc[] =
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
377 "get_ident() -> integer\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
378 \n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
379 Return a non-zero integer that uniquely identifies the current thread\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
380 amongst other threads that exist simultaneously.\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
381 This may be used to identify per-thread resources.\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
382 Even though on some platforms threads identities may appear to be\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
383 allocated consecutive numbers starting at 1, this behavior should not\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
384 be relied upon, and the number should be seen purely as a magic cookie.\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
385 A thread's identity may be reused for another thread after it exits.";
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
386
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
387 static PyMethodDef thread_methods[] = {
8562
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
388 {"start_new_thread", (PyCFunction)thread_start_new_thread, 1,
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
389 start_new_doc},
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
390 {"start_new", (PyCFunction)thread_start_new_thread, 1,
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
391 start_new_doc},
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
392 {"allocate_lock", (PyCFunction)thread_allocate_lock, 0,
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
393 allocate_doc},
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
394 {"allocate", (PyCFunction)thread_allocate_lock, 0,
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
395 allocate_doc},
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
396 {"exit_thread", (PyCFunction)thread_exit_thread, 0,
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
397 exit_doc},
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
398 {"exit", (PyCFunction)thread_exit_thread, 0,
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
399 exit_doc},
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
400 {"get_ident", (PyCFunction)thread_get_ident, 0,
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
401 get_ident_doc},
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
402 #ifndef NO_EXIT_PROG
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
403 {"exit_prog", (PyCFunction)thread_exit_prog},
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
404 #endif
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
405 {NULL, NULL} /* sentinel */
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
406 };
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
407
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
408
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
409 /* Initialization function */
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
410
8562
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
411 static char thread_doc[] =
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
412 "This module provides primitive operations to write multi-threaded programs.\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
413 The 'threading' module provides a more convenient interface.";
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
414
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
415 static char lock_doc[] =
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
416 "A lock object is a synchronization primitive. To create a lock,\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
417 call the allocate_lock() function. Methods are:\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
418 \n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
419 acquire() -- lock the lock, possibly blocking until it can be obtained\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
420 release() -- unlock of the lock\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
421 locked() -- test whether the lock is currently locked\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
422 \n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
423 A lock is not owned by the thread that locked it; another thread may\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
424 unlock it. A thread attempting to lock a lock that it has already locked\n\
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
425 will block until another thread unlocks it. Deadlocks may ensue.";
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
426
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
427 void
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
428 initthread()
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
429 {
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
430 PyObject *m, *d;
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
431
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
432 /* Create the module and add the functions */
8562
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
433 m = Py_InitModule3("thread", thread_methods, thread_doc);
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
434
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
435 /* Add a symbolic constant */
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
436 d = PyModule_GetDict(m);
6367
2c29b8982643 Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents: 5927
diff changeset
437 ThreadError = PyErr_NewException("thread.error", NULL, NULL);
4751
7ab835f87f86 Renamed.
Barry Warsaw <barry@python.org>
parents: 4600
diff changeset
438 PyDict_SetItemString(d, "error", ThreadError);
8562
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
439 Locktype.tp_doc = lock_doc;
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
440 Py_INCREF(&Locktype);
ff9adb57b8b5 Added doc strings. Also export LockType from the modoule, and give it
Guido van Rossum <guido@python.org>
parents: 8433
diff changeset
441 PyDict_SetItemString(d, "LockType", (PyObject *)&Locktype);
923
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
442
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
443 /* Initialize the C thread library */
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
444 init_thread();
72aceed365d4 * Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff changeset
445 }