sim: use Simulator as a contextmanager
authorRobert Jördens <jordens@gmail.com>
Fri, 29 Nov 2013 08:43:44 +0000 (01:43 -0700)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Fri, 29 Nov 2013 22:05:15 +0000 (23:05 +0100)
commit55afab22761048900ed38eee06da5d36bf563fa6
tree1269e5e78ec33f04de0e01244e8e8e771acd836e
parentcf0fb5350fc8ac9bff46e85db40b1e1fe1f98101
sim: use Simulator as a contextmanager

__del__ garbage collector callbacks are too delicate.  E.g. imported
modules can be garbage collected before the objects using them. Can't
use os.remove, socket.SHUT_RDWR...

* added a DeprecationWarning if a Simulator is garbage collected without
having its .close() called
* renamed all gc __del__ callbacks to close()
* implemented context manager hooks for Simulator. Use like

   with Simulator(TestBench()) as s:
       s.run()
migen/sim/generic.py
migen/sim/icarus.py
migen/sim/ipc.py