Tribler: Migrating resources to use "with" statements

Created on 13 Oct 2019  路  4Comments  路  Source: Tribler/tribler

  • [x] I have read CONTRIBUTING.rst
Tribler version/branch+revision:

V7.3.1-RC3 and devel

Operating system and version:

All

I'll start by saying I'm not a developer for the project, but a user.

I noticed in the codebase a number of files (I have counted 11 so far), a couple of sqlite3 connections, and a couple of socket connections, all closed manually and not handled (meaning they're not closed in a "try-finally" at the least) for a possibility of exceptions occurring while said connections are live.

Examples:

Sqlite3 connection:
https://github.com/Tribler/tribler/blob/1b250e16e5d76ff60fe801e22b2dab3bd6907b3b/Tribler/Core/Upgrade/db72_to_pony.py#L91

Socket:
https://github.com/Tribler/tribler/blob/1516936729be1dc00dfa8095810c15893cb6f51e/Tribler/Core/Utilities/network_utils.py#L89

File:
https://github.com/Tribler/tribler/blob/01dda9aedfd0de0860a38523715ecde2740371bf/Tribler/Core/Category/FamilyFilter.py#L26

I'll be happy to aid the project and pull request to migrate said resources to use a "with" statement (which is of course compatible with python 2.5+ and 3.0+).

enhancement

Most helpful comment

@Solomon1732 , you're very welcome to do it!
Create a personal fork of Tribler repository, create a new feature branch from the top of devel, make your changes, creat a PR, have it accepted. That is it!
:wink:

All 4 comments

Hi!

That would be a very nice addition to the code base. Some of the files you linked are over five years old and contain code of many developers that have worked on this project in the past.

Every code contribution that makes Tribler better is more than welcome 馃憤. I think it is the best to coordinate these efforts with @xoriole or @ichorid since they are currently the main developers.

@Solomon1732 , you're very welcome to do it!
Create a personal fork of Tribler repository, create a new feature branch from the top of devel, make your changes, creat a PR, have it accepted. That is it!
:wink:

@ichorid any naming convention for the pull request's/branch's name?

@ichorid any naming convention for the pull request's/branch's name?

Typically, I name feature/fix branches with f_ to distinguish these from special branches.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ichorid picture ichorid  路  8Comments

ichorid picture ichorid  路  11Comments

N0rbert picture N0rbert  路  3Comments

devos50 picture devos50  路  5Comments

filicado picture filicado  路  9Comments