7 # (c) 2005 Straylight/Edgeware
10 #----- Licensing notice -----------------------------------------------------
12 # This file is part of the Python interface to mLib.
14 # mLib/Python is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 2 of the License, or
17 # (at your option) any later version.
19 # mLib/Python is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with mLib/Python; if not, write to the Free Software Foundation,
26 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 SEL_WRITE = _SEL_WRITE
35 cdef readonly unsigned mode
37 def __new__(me, fd, int mode = SEL_READ, readyproc = None,
39 if (mode != _SEL_READ and
40 mode != _SEL_WRITE and
42 raise ValueError, 'bad select mode'
43 sel_initfile(&_sel, &me.f, _getfd(fd), mode, _filefunc, <void *>me)
46 me._readyfunc = _checkcallable(readyproc, 'ready proc')
55 return _tobool(me._activep)
59 def __set__(me, proc):
60 me._readyfunc = _checkcallable(proc, 'ready proc')
65 raise ValueError, 'already enabled'
71 raise ValueError, 'already disabled'
89 return _maybecall(me._readyfunc, ())
91 cdef void _filefunc(int fd, unsigned mode, void *arg):
96 #----- That's all, folks ----------------------------------------------------