Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 4c7f020

Browse files
author
Anselm Kruis
committed
Stackless issue #242: more patchcheck fixes
Fix whitespace, mostly replace tab by spaces. (cherry picked from commit 2e5f7b5)
1 parent ed7910b commit 4c7f020

File tree

11 files changed

+107
-107
lines changed

11 files changed

+107
-107
lines changed

Doc/library/stackless/debugging.rst

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Debugging tools, like those used for tracing, are implemented through
88
calls to the :func:`sys.settrace` function. Now, in |CPY|, when
99
this has been called any code that runs within the operating system thread
1010
is covered by it. In Stackless however, this function only covers the
11-
current tasklet. Stackless provides the tasklet attributes
12-
:attr:`~tasklet.trace_function` and :attr:`~tasklet.profile_function` to
11+
current tasklet. Stackless provides the tasklet attributes
12+
:attr:`~tasklet.trace_function` and :attr:`~tasklet.profile_function` to
1313
get and set the trace/profile function of a particular tasklet.
1414

1515
The debugging related modules, whether :doc:`in the standard library
@@ -19,8 +19,8 @@ In an ideal world, |SLP| might include modified versions of these
1919
modules, and patches adding them would be most welcome.
2020

2121
If you want working debugging for |SLP|, at this time your best
22-
option is to use the `WingWare Python IDE <http://wingware.com>`_
23-
or the `Eclipse IDE with the PyDev-Plugin <http://pydev.org>`_.
22+
option is to use the `WingWare Python IDE <http://wingware.com>`_
23+
or the `Eclipse IDE with the PyDev-Plugin <http://pydev.org>`_.
2424
Both have gone out of their way to add and support |SLP| development.
2525

2626
.. note::
@@ -36,39 +36,39 @@ Tracing tasklets
3636

3737
In order to get debugging support working on a per-tasklet basis, you need to
3838
ensure you enable tracing for all tasklets. This can be archived by the
39-
schedule callback. This callback sees every task switch. Here is
39+
schedule callback. This callback sees every task switch. Here is
4040
a complete example::
4141

4242
from __future__ import absolute_import, print_function
43-
43+
4444
import sys
4545
import stackless
4646
import traceback
47-
48-
47+
48+
4949
class NamedTasklet(stackless.tasklet):
5050
__slots__ = ("name",)
51-
51+
5252
def __init__(self, func, name=None):
5353
stackless.tasklet.__init__(self, func)
5454
if name is None:
5555
name = "at %08x" % (id(self))
5656
self.name = name
57-
57+
5858
def __repr__(self):
5959
return "<tasklet %s>" % (self.name)
60-
61-
60+
61+
6262
class Mutex(object):
63-
63+
6464
def __init__(self, capacity=1):
6565
self.queue = stackless.channel()
6666
self.capacity = capacity
67-
67+
6868
def isLocked(self):
6969
'''return non-zero if locked'''
7070
return self.capacity == 0
71-
71+
7272
def lock(self):
7373
'''acquire the lock'''
7474
currentTasklet = stackless.getcurrent()
@@ -80,7 +80,7 @@ a complete example::
8080
self.queue.receive()
8181
finally:
8282
currentTasklet.set_atomic(atomic)
83-
83+
8484
def unlock(self):
8585
'''release the lock'''
8686
currentTasklet = stackless.getcurrent()
@@ -92,10 +92,10 @@ a complete example::
9292
self.capacity += 1
9393
finally:
9494
currentTasklet.set_atomic(atomic)
95-
95+
9696
m = Mutex()
97-
98-
97+
98+
9999
def task():
100100
name = stackless.getcurrent().name
101101
print(name, "acquiring")
@@ -104,8 +104,8 @@ a complete example::
104104
stackless.schedule()
105105
print(name, "releasing")
106106
m.unlock()
107-
108-
107+
108+
109109
def trace_function(frame, event, arg):
110110
if frame.f_code.co_name in ('schedule_cb', 'channel_cb'):
111111
return None
@@ -114,8 +114,8 @@ a complete example::
114114
if event in ('call', 'line', 'exception'):
115115
return trace_function
116116
return None
117-
118-
117+
118+
119119
def channel_cb(channel, tasklet, sending, willblock):
120120
tf = tasklet.trace_function
121121
try:
@@ -124,8 +124,8 @@ a complete example::
124124
(tasklet, ("recv", "send")[sending], ("", " will block")[willblock]))
125125
finally:
126126
tasklet.trace_function = tf
127-
128-
127+
128+
129129
def schedule_cb(prev, next):
130130
# During a tasklet switch (during the execution of this function) the
131131
# the result of stackless.getcurrent() is implementation defined.
@@ -140,20 +140,20 @@ a complete example::
140140
f_back = current_frame.f_back
141141
if f_back is not None:
142142
current_tf = f_back.f_trace
143-
143+
144144
current_info = "Schedule CB "
145145
if not prev:
146146
print("%sstarting %r" % (current_info, next))
147147
elif not next:
148148
print("%sending %r" % (current_info, prev))
149149
else:
150150
print("%sjumping from %s to %s" % (current_info, prev, next))
151-
151+
152152
# Inform about the installed trace functions
153153
prev_tf = current_tf if prev.frame is current_frame else prev.trace_function
154154
next_tf = current_tf if next.frame is current_frame else next.trace_function
155155
print(" Current trace functions: prev: %r, next: %r" % (prev_tf, next_tf))
156-
156+
157157
# Eventually set a trace function
158158
if next is not None:
159159
if not next.is_main:
@@ -175,20 +175,20 @@ a complete example::
175175
traceback.print_exc()
176176
finally:
177177
sys.settrace(current_tf)
178-
178+
179179
if __name__ == "__main__":
180180
if len(sys.argv) > 1 and sys.argv[1] == 'hard':
181181
stackless.enable_softswitch(False)
182-
182+
183183
stackless.set_channel_callback(channel_cb)
184184
stackless.set_schedule_callback(schedule_cb)
185-
185+
186186
NamedTasklet(task, "tick")()
187187
NamedTasklet(task, "trick")()
188188
NamedTasklet(task, "track")()
189-
189+
190190
stackless.run()
191-
191+
192192
stackless.set_channel_callback(None)
193193
stackless.set_schedule_callback(None)
194194

@@ -199,13 +199,13 @@ a complete example::
199199

200200
.. note::
201201

202-
This section is out dated and only of historical interest. Since the
203-
implementation of :attr:`~tasklet.trace_function` and
202+
This section is out dated and only of historical interest. Since the
203+
implementation of :attr:`~tasklet.trace_function` and
204204
:attr:`~tasklet.profile_function` a debugger can enable tracing or profiling
205205
within the schedule callback without monkey patching.
206-
206+
207207
In order to get debugging support working on a per-tasklet basis, you need to
208-
ensure you call :func:`sys.settrace` for all tasklets. Vilhelm Saevarsson
208+
ensure you call :func:`sys.settrace` for all tasklets. Vilhelm Saevarsson
209209
`has an email
210210
<http://www.stackless.com/pipermail/stackless/2007-October/003074.html>`_
211211
giving code and a description of the steps required including potentially
@@ -215,7 +215,7 @@ Vilhelm's code::
215215

216216
import sys
217217
import stackless
218-
218+
219219
def contextDispatch( prev, next ):
220220
if not prev: #Creating next
221221
# I never see this print out
@@ -232,7 +232,7 @@ Vilhelm's code::
232232
if not next.frame.f_trace:
233233
# We might already be tracing so ...
234234
sys.call_tracing(next.settrace, (traceDispatch, ))
235-
235+
236236
stackless.set_schedule_callback(contextDispatch)
237237

238238
def __call__(self, *args, **kwargs):
@@ -243,11 +243,11 @@ Vilhelm's code::
243243
sys.settrace(None)
244244
self.tempval = new_f
245245
stackless.tasklet.setup(self, f, args, kwargs)
246-
246+
247247
def settrace( self, tb ):
248248
self.frame.f_trace = tb
249249
sys.settrace(tb)
250-
250+
251251
stackless.tasklet.__call__ = __call__
252252
stackless.tasklet.settrace = settrace
253253

Doc/library/stackless/threads.rst

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ want to make use of more than one thread.
2222
Tasklets and Threads
2323
--------------------
2424

25-
A tasklet usually has an associated thread. This thread is identified by the
26-
attribute :attr:`tasklet.thread_id`. A newly created tasklet is always
27-
associated with its creator thread.
25+
A tasklet usually has an associated thread. This thread is identified by the
26+
attribute :attr:`tasklet.thread_id`. A newly created tasklet is always
27+
associated with its creator thread.
2828

29-
The associated thread of a tasklet changes only as the result of
30-
a :meth:`tasklet.bind_thread` call or if the associated thread
31-
terminates. In the later case the thread id becomes ``-1``. Application
29+
The associated thread of a tasklet changes only as the result of
30+
a :meth:`tasklet.bind_thread` call or if the associated thread
31+
terminates. In the later case the thread id becomes ``-1``. Application
3232
code can bind the tasklet to another thread using :meth:`~tasklet.bind_thread`.
3333

34-
When a thread dies, only tasklets with a C-state are actively killed.
35-
Soft-switched tasklets simply stop. All tasklets bound to the thread will
34+
When a thread dies, only tasklets with a C-state are actively killed.
35+
Soft-switched tasklets simply stop. All tasklets bound to the thread will
3636
lose their thread-state, which means that their :attr:`~tasklet.thread_id`
37-
will report as ``-1``. This also includes soft-switched tasklets,
37+
will report as ``-1``. This also includes soft-switched tasklets,
3838
which share a C-state.
3939

4040
The reason Stackless kills tasklets with C-state is that not doing so
@@ -45,8 +45,8 @@ with a C-state. Stackless cannot
4545
kill soft-switched tasklets, because there is no central list of them.
4646
Stackless only knows about the hard-switched ones.
4747

48-
Threads that end really should make sure that they finish whatever worker
49-
tasklets they have going by manually killing (``tasklet.kill()``) or
48+
Threads that end really should make sure that they finish whatever worker
49+
tasklets they have going by manually killing (``tasklet.kill()``) or
5050
unbinding (``tasklet.bind(None)``) them, but that is up to application code.
5151

5252
During interpreter shutdown Stackless kills other daemon threads (non-daemon
@@ -69,7 +69,7 @@ Example - scheduler per thread::
6969

7070
import threading
7171
import stackless
72-
72+
7373
def secondary_thread_func():
7474
print("THREAD(2): Has", stackless.runcount, "tasklets in its scheduler")
7575

@@ -78,12 +78,12 @@ Example - scheduler per thread::
7878
while thread.is_alive():
7979
stackless.schedule()
8080
print("THREAD(1): Death of THREAD(2) detected")
81-
81+
8282
mainThreadTasklet = stackless.tasklet(main_thread_func)()
83-
83+
8484
thread = threading.Thread(target=secondary_thread_func)
8585
thread.start()
86-
86+
8787
stackless.run()
8888

8989
Output::

Doc/whatsnew/stackless.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ For other changes see :ref:`whatsnew-index`.
1010
.. include:: ../../Stackless/changelog.txt
1111
:literal:
1212
:encoding: utf-8
13-
13+

Include/descrobject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct wrapperbase {
3232
int flags;
3333
PyObject *name_strobj;
3434
#ifdef STACKLESS
35-
int slp_offset;
35+
int slp_offset;
3636
#endif
3737
};
3838

@@ -73,7 +73,7 @@ typedef struct {
7373
struct wrapperbase *d_base;
7474
void *d_wrapped; /* This can be any function pointer */
7575
#ifdef STACKLESS
76-
int d_slpmask;
76+
int d_slpmask;
7777
#endif
7878
} PyWrapperDescrObject;
7979
#endif /* Py_LIMITED_API */

0 commit comments

Comments
 (0)