Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
1d8fb2d8
Commit
1d8fb2d8
authored
Jun 28, 1998
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added doc strings.
parent
a5e1b008
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
10 deletions
+98
-10
Modules/selectmodule.c
Modules/selectmodule.c
+30
-2
Modules/signalmodule.c
Modules/signalmodule.c
+68
-8
No files found.
Modules/selectmodule.c
View file @
1d8fb2d8
...
...
@@ -314,18 +314,46 @@ select_select(self, args)
return
ret
;
}
static
char
select_doc
[]
=
"select(rlist, wlist, xlist[, timeout]) -> (rlist, wlist, xlist)
\n
\
\n
\
Wait until one or more file descriptors are ready for some kind of I/O.
\n
\
The first three arguments are lists of file descriptors to be waited for:
\n
\
rlist -- wait until ready for reading
\n
\
wlist -- wait until ready for writing
\n
\
xlist -- wait for an ``exceptional condition''
\n
\
If only one kind of condition is required, pass [] for the other lists.
\n
\
A file descriptor is either a socket or file object, or a small integer
\n
\
gotten from a fileno() method call on one of those.
\n
\
\n
\
The optional 4th argument specifies a timeout in seconds; it may be
\n
\
a floating point number to specify fractions of seconds. If it is absent
\n
\
or None, the call will never time out.
\n
\
\n
\
The return value is a tuple of three lists corresponding to the first three
\n
\
arguments; each contains the subset of the corresponding file descriptors
\n
\
that are ready.
\n
\
\n
\
*** IMPORTANT NOTICE ***
\n
\
On Windows, only sockets are supported; on Unix, all file descriptors."
;
static
PyMethodDef
select_methods
[]
=
{
{
"select"
,
select_select
,
1
},
{
"select"
,
select_select
,
1
,
select_doc
},
{
0
,
0
},
/* sentinel */
};
static
char
module_doc
[]
=
"This module supports asynchronous I/O on multiple file descriptors.
\n
\
\n
\
*** IMPORTANT NOTICE ***
\n
\
On Windows, only sockets are supported; on Unix, all file descriptors."
;
void
initselect
()
{
PyObject
*
m
,
*
d
;
m
=
Py_InitModule
(
"select"
,
select_methods
);
m
=
Py_InitModule
3
(
"select"
,
select_methods
,
module_doc
);
d
=
PyModule_GetDict
(
m
);
SelectError
=
PyErr_NewException
(
"select.error"
,
NULL
,
NULL
);
PyDict_SetItemString
(
d
,
"error"
,
SelectError
);
...
...
Modules/signalmodule.c
View file @
1d8fb2d8
...
...
@@ -122,6 +122,12 @@ signal_default_int_handler(self, arg)
return
NULL
;
}
static
char
default_int_handler_doc
[]
=
"default_int_handler(...)
\n
\
\n
\
The default handler for SIGINT instated by Python.
\n
\
It raises KeyboardInterrupt."
;
static
RETSIGTYPE
signal_handler
(
sig_num
)
...
...
@@ -164,6 +170,11 @@ signal_alarm(self, args)
/* alarm() returns the number of seconds remaining */
return
PyInt_FromLong
(
alarm
(
t
));
}
static
char
alarm_doc
[]
=
"alarm(seconds)
\n
\
\n
\
Arrange for SIGALRM to arrive after the given number of seconds."
#endif
#ifdef HAVE_PAUSE
...
...
@@ -187,6 +198,11 @@ signal_pause(self, args)
Py_INCREF
(
Py_None
);
return
Py_None
;
}
static
char
pause_doc
[]
=
"pause()
Wait until a signal arrives."
;
#endif
...
...
@@ -235,9 +251,20 @@ signal_signal(self, args)
return
old_handler
;
}
static
char
signal_doc
[]
=
"signal(sig, action) -> action
\n
\
\n
\
Set the action for the given signal. The action can be SIG_DFL,
\n
\
SIG_IGN, or a callable Python object. The previous action is
\n
\
returned. See getsignal() for possible return values.
\n
\
\n
\
*** IMPORTANT NOTICE ***
\n
\
A signal handler function is called with two arguments:
\n
\
the first is the signal number, the second is the interrupted stack frame."
;
static
PyObject
*
signal_get
_
signal
(
self
,
args
)
signal_getsignal
(
self
,
args
)
PyObject
*
self
;
/* Not used */
PyObject
*
args
;
{
...
...
@@ -255,24 +282,57 @@ signal_get_signal(self, args)
return
old_handler
;
}
static
char
getsignal_doc
[]
=
"getsignal(sig) -> action
\n
\
\n
\
Return the current action for the given signal. The return value can be:
\n
\
SIG_IGN -- if the signal is being ignored
\n
\
SIG_DFL -- if the default action for the signal is in effect
\n
\
None -- if an unknown handler is in effect
\n
\
anything else -- the callable Python object used as a handler
\n
\
"
;
/* List of functions defined in the module */
static
PyMethodDef
signal_methods
[]
=
{
#ifdef HAVE_ALARM
{
"alarm"
,
signal_alarm
},
{
"alarm"
,
signal_alarm
,
0
,
alarm_doc
},
#endif
{
"signal"
,
signal_signal
},
{
"getsignal"
,
signal_get
_signal
},
{
"signal"
,
signal_signal
,
0
,
signal_doc
},
{
"getsignal"
,
signal_get
signal
,
0
,
getsignal_doc
},
#ifdef HAVE_PAUSE
{
"pause"
,
signal_pause
},
{
"pause"
,
signal_pause
,
0
,
pause_doc
},
#endif
{
"default_int_handler"
,
signal_default_int_handler
},
{
NULL
,
NULL
}
/* sentinel */
{
"default_int_handler"
,
signal_default_int_handler
,
0
,
default_int_handler_doc
},
{
NULL
,
NULL
}
/* sentinel */
};
static
char
module_doc
[]
=
"This module provides mechanisms to use signal handlers in Python.
\n
\
\n
\
Functions:
\n
\
\n
\
alarm() -- cause SIGALRM after a specified time [Unix only]
\n
\
signal() -- set the action for a given signal
\n
\
getsignal() -- get the signal action for a given signal
\n
\
pause() -- wait until a signal arrives [Unix only]
\n
\
default_int_handler() -- default SIGINT handler
\n
\
\n
\
Constants:
\n
\
\n
\
SIG_DFL -- used to refer to the system default handler
\n
\
SIG_IGN -- used to ignore the signal
\n
\
NSIG -- number of defined signals
\n
\
\n
\
SIGINT, SIGTERM, etc. -- signal numbers
\n
\
\n
\
*** IMPORTANT NOTICE ***
\n
\
A signal handler function is called with two arguments:
\n
\
the first is the signal number, the second is the interrupted stack frame."
;
void
initsignal
()
{
...
...
@@ -285,7 +345,7 @@ initsignal()
#endif
/* Create the module and add the functions */
m
=
Py_InitModule
(
"signal"
,
signal_methods
);
m
=
Py_InitModule
3
(
"signal"
,
signal_methods
,
module_doc
);
/* Add some symbolic constants to the module */
d
=
PyModule_GetDict
(
m
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment