From: Cacilhας, La Batalema Date: Thu, 11 Jul 2013 18:46:16 +0000 (-0300) Subject: bugfix: close forgotten file descriptors X-Git-Tag: rel_0_6_0~1^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=673abcbfa259539d395f3f5fde67638679fd9b42;p=thirdparty%2Fsqlalchemy%2Falembic.git bugfix: close forgotten file descriptors --- diff --git a/alembic/command.py b/alembic/command.py index 095d041f..26fc148c 100644 --- a/alembic/command.py +++ b/alembic/command.py @@ -9,11 +9,11 @@ def list_templates(config): config.print_stdout("Available templates:\n") for tempname in os.listdir(config.get_template_directory()): - readme = os.path.join( + with open(os.path.join( config.get_template_directory(), tempname, - 'README') - synopsis = open(readme).next() + 'README')) as readme: + synopsis = readme.next() config.print_stdout("%s - %s", tempname, synopsis) config.print_stdout("\nTemplates are used via the 'init' command, e.g.:") diff --git a/alembic/templates/multidb/env.py b/alembic/templates/multidb/env.py index b5f205c3..fc2d3ba4 100644 --- a/alembic/templates/multidb/env.py +++ b/alembic/templates/multidb/env.py @@ -64,12 +64,10 @@ def run_migrations_offline(): logger.info("Migrating database %s" % name) file_ = "%s.sql" % name logger.info("Writing output to %s" % file_) - context.configure( - url=rec['url'], - output_buffer=open(file_, 'w') - ) - with context.begin_transaction(): - context.run_migrations(engine_name=name) + with open(file_, 'w') as buffer: + context.configure(url=rec['url'], output_buffer=buffer) + with context.begin_transaction(): + context.run_migrations(engine_name=name) def run_migrations_online(): """Run migrations in 'online' mode.