diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2017-07-27 18:08:01 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2017-07-27 18:08:01 +0200 |
commit | 92b23e1e636a82652c63082b12ffcabf62d9e9f9 (patch) | |
tree | ad39d7d355285a49d906f927e9d77b1d6d0061ed | |
parent | 898c0d7fdd10e2d70f3627c6d50740b203f817d8 (diff) | |
download | pysendfile-92b23e1e636a82652c63082b12ffcabf62d9e9f9.tar.gz |
fix C compilation warning + PEP8 failures
-rw-r--r--[-rwxr-xr-x] | .ci/travis/install.sh | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | .ci/travis/run.sh | 0 | ||||
-rw-r--r-- | Makefile | 9 | ||||
-rw-r--r-- | README.rst | 14 | ||||
-rw-r--r-- | sendfilemodule.c | 26 | ||||
-rw-r--r-- | setup.py | 1 | ||||
-rw-r--r-- | test/test_sendfile.py | 2 |
7 files changed, 28 insertions, 24 deletions
diff --git a/.ci/travis/install.sh b/.ci/travis/install.sh index 0d21032..0d21032 100755..100644 --- a/.ci/travis/install.sh +++ b/.ci/travis/install.sh diff --git a/.ci/travis/run.sh b/.ci/travis/run.sh index eb92ee8..eb92ee8 100755..100644 --- a/.ci/travis/run.sh +++ b/.ci/travis/run.sh @@ -38,18 +38,15 @@ uninstall: test: install $(PYTHON) $(TSCRIPT) -# requires "pip install pep8" pep8: - @git ls-files | grep \\.py$ | xargs pep8 + @git ls-files | grep \\.py$ | xargs $(PYTHON) -m pep8 -# requires "pip install pyflakes" pyflakes: @export PYFLAKES_NODOCTEST=1 && \ - git ls-files | grep \\.py$ | xargs pyflakes + git ls-files | grep \\.py$ | xargs $(PYTHON) -m pyflakes -# requires "pip install flake8" flake8: - @git ls-files | grep \\.py$ | xargs flake8 + @git ls-files | grep \\.py$ | xargs $(PYTHON) -m flake8 # upload source tarball on https://pypi.python.org/pypi/pysendfile. upload-src: clean @@ -1,7 +1,3 @@ -.. image:: https://img.shields.io/pypi/dm/pysendfile.svg - :target: https://pypi.python.org/pypi/pysendfile#downloads - :alt: Downloads this month - .. image:: https://api.travis-ci.org/giampaolo/pysendfile.png?branch=master :target: https://travis-ci.org/giampaolo/pysendfile :alt: Linux tests (Travis) @@ -171,6 +167,16 @@ Differences with send() `test suite <https://github.com/giampaolo/pysendfile/blob/release-2.0.1/test/test_sendfile.py#L202>`__, `pyftpdlib wrapper <http://code.google.com/p/pyftpdlib/source/browse/tags/release-0.7.0/pyftpdlib/ftpserver.py#1035>`__. +=============== +Non-blocking IO +=============== + +- sendfile(2) can be used with non-blocking sockets, meaning if you try to + send a chunk of data over a socket fd which is not "ready" you'll immediately + get EAGAIN (then you can retry later by using `select()`, `epoll()` or + whatever). +- the regular file fd, on the other hand, *can* block + =================== Supported platforms =================== diff --git a/sendfilemodule.c b/sendfilemodule.c index fd69af6..b1ed55b 100644 --- a/sendfilemodule.c +++ b/sendfilemodule.c @@ -6,12 +6,11 @@ * Original author: * Copyright (C) 2005 Ben Woolley <user tautolog at gmail> * - * The AIX support code is: - * Copyright (C) 2008,2009 Niklas Edmundsson <nikke@acc.umu.se> - * - * Rewritten from scratch and maintained by Giampaolo Rodola' - * Copyright (C) 2009,2014 <g.rodola@gmail.com> + * AIX implementation: + * Copyright (C) 2008, 2009 Niklas Edmundsson <nikke@acc.umu.se> * + * Rewritten from scratch and maintained Giampaolo Rodola'; + * Copyright (C) 2009, present day Giampaolo Rodola' <g.rodola@gmail.com> * * The MIT License * @@ -159,11 +158,11 @@ method_sendfile(PyObject *self, PyObject *args, PyObject *kwdict) goto done; done: - #if defined(HAVE_LARGEFILE_SUPPORT) - return Py_BuildValue("L", sent); - #else - return Py_BuildValue("l", sent); - #endif +#if defined(HAVE_LARGEFILE_SUPPORT) + return Py_BuildValue("L", sent); +#else + return Py_BuildValue("l", sent); +#endif } /* --- end OSX / FreeBSD / Dragonfly --- */ @@ -223,11 +222,11 @@ method_sendfile(PyObject *self, PyObject *args) return NULL; } else { - #if defined(HAVE_LARGEFILE_SUPPORT) +#if defined(HAVE_LARGEFILE_SUPPORT) return Py_BuildValue("L", sts); - #else +#else return Py_BuildValue("l", sts); - #endif +#endif } } /* --- end AIX --- */ @@ -312,7 +311,6 @@ struct module_state { #define GETSTATE(m) ((struct module_state*)PyModule_GetState(m)) #else #define GETSTATE(m) (&_state) -static struct module_state _state; #endif static PyMethodDef sendfile_methods[] = { @@ -82,5 +82,6 @@ def main(): sources=['sendfilemodule.c'], libraries=libraries)]) + if __name__ == '__main__': main() diff --git a/test/test_sendfile.py b/test/test_sendfile.py index ce223b1..2d688f0 100644 --- a/test/test_sendfile.py +++ b/test/test_sendfile.py @@ -55,6 +55,7 @@ def b(x): return bytes(x, 'ascii') return x + TESTFN = "$testfile" TESTFN2 = TESTFN + "2" TESTFN3 = TESTFN + "3" @@ -543,6 +544,7 @@ def cleanup(): safe_remove(TESTFN) safe_remove(TESTFN2) + atexit.register(cleanup) |