interface.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Copyright 2011 Facebook
00004 #
00005 # Licensed under the Apache License, Version 2.0 (the "License"); you may
00006 # not use this file except in compliance with the License. You may obtain
00007 # a copy of the License at
00008 #
00009 #     http://www.apache.org/licenses/LICENSE-2.0
00010 #
00011 # Unless required by applicable law or agreed to in writing, software
00012 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00013 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
00014 # License for the specific language governing permissions and limitations
00015 # under the License.
00016 
00017 """Interfaces for platform-specific functionality.
00018 
00019 This module exists primarily for documentation purposes and as base classes
00020 for other tornado.platform modules.  Most code should import the appropriate
00021 implementation from `tornado.platform.auto`.
00022 """
00023 
00024 from __future__ import absolute_import, division, with_statement
00025 
00026 
00027 def set_close_exec(fd):
00028     """Sets the close-on-exec bit (``FD_CLOEXEC``)for a file descriptor."""
00029     raise NotImplementedError()
00030 
00031 
00032 class Waker(object):
00033     """A socket-like object that can wake another thread from ``select()``.
00034 
00035     The `~tornado.ioloop.IOLoop` will add the Waker's `fileno()` to
00036     its ``select`` (or ``epoll`` or ``kqueue``) calls.  When another
00037     thread wants to wake up the loop, it calls `wake`.  Once it has woken
00038     up, it will call `consume` to do any necessary per-wake cleanup.  When
00039     the ``IOLoop`` is closed, it closes its waker too.
00040     """
00041     def fileno(self):
00042         """Returns a file descriptor for this waker.
00043 
00044         Must be suitable for use with ``select()`` or equivalent on the
00045         local platform.
00046         """
00047         raise NotImplementedError()
00048 
00049     def wake(self):
00050         """Triggers activity on the waker's file descriptor."""
00051         raise NotImplementedError()
00052 
00053     def consume(self):
00054         """Called after the listen has woken up to do any necessary cleanup."""
00055         raise NotImplementedError()
00056 
00057     def close(self):
00058         """Closes the waker's file descriptor(s)."""
00059         raise NotImplementedError()


roswww
Author(s): Jonathan Mace
autogenerated on Thu Jan 2 2014 11:53:30