METADATA 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. Metadata-Version: 2.1
  2. Name: portalocker
  3. Version: 1.7.1
  4. Summary: Wraps the portalocker recipe for easy usage
  5. Home-page: https://github.com/WoLpH/portalocker
  6. Author: Rick van Hattem
  7. Author-email: wolph@wol.ph
  8. License: PSF
  9. Keywords: locking,locks,with statement,windows,linux,unix
  10. Platform: any
  11. Classifier: Intended Audience :: Developers
  12. Classifier: Programming Language :: Python
  13. Classifier: Programming Language :: Python :: 2.7
  14. Classifier: Programming Language :: Python :: 3.3
  15. Classifier: Programming Language :: Python :: 3.4
  16. Classifier: Programming Language :: Python :: 3.5
  17. Classifier: Programming Language :: Python :: 3.6
  18. Classifier: Programming Language :: Python :: Implementation :: CPython
  19. Classifier: Programming Language :: Python :: Implementation :: PyPy
  20. Requires-Dist: pywin32 (!=226) ; platform_system == "Windows"
  21. Provides-Extra: docs
  22. Requires-Dist: sphinx (>=1.7.1) ; extra == 'docs'
  23. Provides-Extra: tests
  24. Requires-Dist: pytest (>=4.6.9) ; extra == 'tests'
  25. Requires-Dist: pytest-cov (>=2.8.1) ; extra == 'tests'
  26. Requires-Dist: sphinx (>=1.8.5) ; extra == 'tests'
  27. Requires-Dist: pytest-flake8 (>=1.0.5) ; extra == 'tests'
  28. ############################################
  29. portalocker - Cross-platform locking library
  30. ############################################
  31. .. image:: https://travis-ci.org/WoLpH/portalocker.svg?branch=master
  32. :alt: Linux Test Status
  33. :target: https://travis-ci.org/WoLpH/portalocker
  34. .. image:: https://ci.appveyor.com/api/projects/status/mgqry98hgpy4prhh?svg=true
  35. :alt: Windows Tests Status
  36. :target: https://ci.appveyor.com/project/WoLpH/portalocker
  37. .. image:: https://coveralls.io/repos/WoLpH/portalocker/badge.svg?branch=master
  38. :alt: Coverage Status
  39. :target: https://coveralls.io/r/WoLpH/portalocker?branch=master
  40. Overview
  41. --------
  42. Portalocker is a library to provide an easy API to file locking.
  43. An important detail to note is that on Linux and Unix systems the locks are
  44. advisory by default. By specifying the `-o mand` option to the mount command it
  45. is possible to enable mandatory file locking on Linux. This is generally not
  46. recommended however. For more information about the subject:
  47. - https://en.wikipedia.org/wiki/File_locking
  48. - http://stackoverflow.com/questions/39292051/portalocker-does-not-seem-to-lock
  49. - https://stackoverflow.com/questions/12062466/mandatory-file-lock-on-linux
  50. The module is currently maintained by Rick van Hattem <Wolph@wol.ph>.
  51. The project resides at https://github.com/WoLpH/portalocker . Bugs and feature
  52. requests can be submitted there. Patches are also very welcome.
  53. Tips
  54. ----
  55. On some networked filesystems it might be needed to force a `os.fsync()` before
  56. closing the file so it's actually written before another client reads the file.
  57. Effectively this comes down to:
  58. ::
  59. with portalocker.Lock('some_file', 'rb+', timeout=60) as fh:
  60. # do what you need to do
  61. ...
  62. # flush and sync to filesystem
  63. fh.flush()
  64. os.fsync(fh.fileno())
  65. Links
  66. -----
  67. * Documentation
  68. - http://portalocker.readthedocs.org/en/latest/
  69. * Source
  70. - https://github.com/WoLpH/portalocker
  71. * Bug reports
  72. - https://github.com/WoLpH/portalocker/issues
  73. * Package homepage
  74. - https://pypi.python.org/pypi/portalocker
  75. * My blog
  76. - http://w.wol.ph/
  77. Examples
  78. --------
  79. To make sure your cache generation scripts don't race, use the `Lock` class:
  80. >>> import portalocker
  81. >>> with portalocker.Lock('somefile', timeout=1) as fh:
  82. print >>fh, 'writing some stuff to my cache...'
  83. To customize the opening and locking a manual approach is also possible:
  84. >>> import portalocker
  85. >>> file = open('somefile', 'r+')
  86. >>> portalocker.lock(file, portalocker.LOCK_EX)
  87. >>> file.seek(12)
  88. >>> file.write('foo')
  89. >>> file.close()
  90. Explicitly unlocking might not be needed in all cases:
  91. https://github.com/AzureAD/microsoft-authentication-extensions-for-python/issues/42#issuecomment-601108266
  92. But can be done through:
  93. >>> portalocker.unlock(file)
  94. Do note that your data might still be in a buffer so it is possible that your
  95. data is not available until you `flush()` or `close()`.
  96. More examples can be found in the
  97. `tests <http://portalocker.readthedocs.io/en/latest/_modules/tests/tests.html>`_.
  98. Changelog
  99. ---------
  100. See the `changelog <http://portalocker.readthedocs.io/en/latest/changelog.html>`_ page.
  101. License
  102. -------
  103. See the `LICENSE <https://github.com/WoLpH/portalocker/blob/develop/LICENSE>`_ file.