Comments (9)
Feature or bug...the ResourceWanring issues should be somehow handled. It is not very helpful and not trustworthy for people running Zope or Plone in production with tons of such messages in the logs for standard operations.
from transaction.
I have recently added a new feature to zope.testrunner
which should significantly facilitate the analysis of reference cycles: --gc-after-test -vvvv
. The extension is in master
(not yet released).
from transaction.
from transaction.
The transaction could (and I think does normally) break its connection to the data (aka resource) managers in a commit/abort - thus breaking the cycle.
That's an excellent point. Transaction.commit()
calls Transaction._free()
(which unjoins all the IDataManagers with del self._resources
) in the case that no exception is raised by a resource manager. That should break the obvious cycle.
But in this particular test case, the resource warning doesn't show up until the garbage collector runs, and it always shows up exactly when you run the collector, which (I think) means that there was a cycle involved:
//lib/python3.7/site-packages/zope/testrunner/runner.py:408: ResourceWarning: unclosed <socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 55893), raddr=('127.0.0.1', 5432)>
gc.collect()
There must be some other cycle...
from transaction.
...Transaction.commit() calls Transaction._free() (which unjoins all the IDataManagers with del self._resources) in the case that no exception is raised by a resource manager. ...
Looks like we had a bug here: _free
should be called, too, when _commitResources
raises an exception and not only when it succeeds (maybe same thing for the synchronizers). However, this is likely not the cause for the observed cycle.
from transaction.
Looks like we had a bug here:
_free
should be called, too, when_commitResources
raises an exception and not only when it succeeds (maybe same thing for the synchronizers). However, this is likely not the cause for the observed cycle.
Likely a feature (not a bug): not calling _free
facilitates the analysis of potential problems (transaction and resource managers are still available for analysis); the transaction is (hopefully) doomed and will get finished/cleaned up by a following abort
.
from transaction.
I had a branch where I tested doing more cleanups (having _free()
drop its reference to _manager
and _synchronizers
, among other things) and it didn't make a difference. I'm fully convinced the cycle is elsewhere, so I'm going to close this issue.
I decided not to pursue that branch into a PR because (a) it didn't fix the problem and (b) there were some subtle semantic differences. Notably, in the abort()
case, currently the synchronizer afterCompletion
methods were called after the transaction had been freed (meaning they could begin another one) --- in the commit()
case, currently the afterCompletion
methods were called before the transaction had been freed. The branch made that consistent, always calling them before the transaction had been freed, but it's not clear to me that was correct or desired (even though all of RelStorage's tests pass with that change). I'll leave that branch around for awhile in case anyone does want to pursue it.
I'd like to make a release of transaction 3.0 to get the new hook functionality out. If there are no objections I'll plan on doing that in a day or so.
from transaction.
The error is still open in ZODB 5.7.0 (Plone 6.0.0a4) where I see this error frequently:
/Users/ajung/src/plone6.buildout/eggs/ZODB-5.7.0-py3.9.egg/ZODB/blob.py:338: ResourceWarning: unclosed file <_io.FileIO name='/Users/ajung/src/plone6.buildout/var/blobstorage/0x00/0x00/0x00/0x00/0x01/0x88/0xa1/0xa6/0x03e8a997b8fa1233.blob' mode='rb' closefd=True>
from transaction.
I just released https://pypi.org/project/zope.testrunner/5.5/ containing the changed @d-maurer mentioned.
from transaction.
Related Issues (20)
- 3.0.1: pytest warnings HOT 8
- 3.0.1: setuptools build_sphinx command fails HOT 11
- 3.0.1: transaction not sphinx 4.0.x ready? HOT 5
- Print the stack when a resource manager joins a transaction HOT 4
- Question: Nested transaction.manager HOT 2
- Add support for QA tooling? HOT 3
- 3.0.1: sphinx warnings `reference target not found` HOT 1
- Transactions with multiprocessing HOT 2
- Question: How to find a transaction’s data manager, if any? HOT 1
- No status to indicate aborted transaction. HOT 7
- Reach 100% coverage HOT 1
- DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working HOT 2
- 'ThreadTransactionManager' object has no attribute '_retryable' HOT 1
- Support abort hooks (symmetrically to commit hooks) HOT 1
- Docs: Confusion between resource and data managers HOT 1
- Still possible to join aborted and doomed transactions
- RTD integration broken HOT 2
- Remove legacy functionality from ITransactionDeprecated
- transaction 3.0 breaks afterCommitHooks HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from transaction.