[ditrack commit] r1617 - src/trunk/DITrack/DB

Vlad Skvortsov vss at 73rus.com
Sun May 20 13:00:33 PDT 2007


Hmm, can you give some explanations regarding this commit? What is the 
possible scenario that would render "lockfd" unbound?

In general, my own preference is to have as few conditionals as possible 
(to test as few executions paths as possible), so if there is no 
compelling reason to have this functionality, I'd rather want to remove 
these.

gli at ditrack.org wrote:
> Author: gli
> Date: 2007-05-20 03:49:11 -0700 (Sun, 20 May 2007)
> New Revision: 1617
>
> Modified:
>    src/trunk/DITrack/DB/Common.py
> Log:
> function unlock() now work with the file descriptor through arguments
>
> Modified: src/trunk/DITrack/DB/Common.py
> ===================================================================
> --- src/trunk/DITrack/DB/Common.py	2007-05-18 20:41:35 UTC (rev 1616)
> +++ src/trunk/DITrack/DB/Common.py	2007-05-20 10:49:11 UTC (rev 1617)
> @@ -167,7 +167,8 @@
>  
>      def __del__(self):
>          # Unlock database
> -        self.unlock()
> +        if hasattr(self, "lockfd"):
> +            self.unlock(self.lockfd)
>  
>      def __getitem__(self, key):
>          """
> @@ -382,7 +383,6 @@
>              os.mkdir(datadir, 0755)
>  
>          lock_fname = os.path.join(datadir, LOCK_FILE)
> -        self.lockfd = None
>  
>          if not os.path.exists(lock_fname):
>              # if there's no lock file - create it and lock it
> @@ -518,11 +518,11 @@
>          # contained in the LMA issue
>          self.lma.remove_comment(issue_id, comment_name)
>  
> -    def unlock(self):
> +    def unlock(self, lockfd):
>          # if database path is wrong, object doesn't have lockfd attribute
> -        if hasattr(self, "lockfd") and self.lockfd:
> -            fcntl.flock(self.lockfd.fileno(), fcntl.LOCK_UN)
> -            os.unlink(self.lockfd.name)
> +        if lockfd:
> +            fcntl.flock(lockfd.fileno(), fcntl.LOCK_UN)
> +            os.unlink(lockfd.name)
>  
>  
>  class Filter:
>
> _______________________________________________
> Commit mailing list
> Commit at lists.ditrack.org
> http://lists.ditrack.org/mailman/listinfo/commit
>   


-- 
Vlad Skvortsov, vss at 73rus.com, http://vss.73rus.com



More information about the Dev mailing list