1 |
commit: 434998b389419ad929a53540057f80d4a921ea7b |
2 |
Author: André Erdmann <dywi <AT> mailerd <DOT> de> |
3 |
AuthorDate: Mon Jul 2 16:44:20 2012 +0000 |
4 |
Commit: André Erdmann <dywi <AT> mailerd <DOT> de> |
5 |
CommitDate: Mon Jul 2 16:44:20 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=434998b3 |
7 |
|
8 |
Manifest creation: use one instance per job |
9 |
|
10 |
modified: roverlay/manifest/helpers.py |
11 |
|
12 |
--- |
13 |
roverlay/manifest/helpers.py | 29 ++++++++++++++++++++--------- |
14 |
1 files changed, 20 insertions(+), 9 deletions(-) |
15 |
|
16 |
diff --git a/roverlay/manifest/helpers.py b/roverlay/manifest/helpers.py |
17 |
index 5e2919c..47e1e20 100644 |
18 |
--- a/roverlay/manifest/helpers.py |
19 |
+++ b/roverlay/manifest/helpers.py |
20 |
@@ -12,14 +12,13 @@ import re |
21 |
import copy |
22 |
import logging |
23 |
import subprocess |
24 |
+import threading |
25 |
|
26 |
from roverlay import config, util |
27 |
|
28 |
class _ManifestCreation ( object ): |
29 |
"""This is the base class for Manifest file creation.""" |
30 |
|
31 |
- static_instance = None |
32 |
- |
33 |
def __init__ ( self ): |
34 |
self.logger = logging.getLogger ( 'ManifestCreation' ) |
35 |
# --- end of __init__ (...) --- |
36 |
@@ -31,11 +30,8 @@ class _ManifestCreation ( object ): |
37 |
|
38 |
@classmethod |
39 |
def do ( cls, package_info ): |
40 |
- """Class/static access to Manifest creation.""" |
41 |
- if cls.static_instance is None: |
42 |
- cls.static_instance = cls() |
43 |
- |
44 |
- return cls.static_instance.create_for ( package_info ) |
45 |
+ """Class access to Manifest creation.""" |
46 |
+ return cls().create_for ( package_info ) |
47 |
# --- end of do (...) --- |
48 |
|
49 |
|
50 |
@@ -44,9 +40,24 @@ class ExternalManifestCreation ( _ManifestCreation ): |
51 |
interface, ebuild(1), which is called in a filtered environment. |
52 |
""" |
53 |
|
54 |
+ envlock = threading.Lock() |
55 |
+ manifest_env = None |
56 |
+ |
57 |
+ @classmethod |
58 |
+ def get_env ( cls, repo_dir ): |
59 |
+ cls.envlock.acquire() |
60 |
+ try: |
61 |
+ if cls.manifest_env is None: |
62 |
+ cls.manifest_env = ManifestEnv ( filter_env=True ) |
63 |
+ ret = cls.manifest_env [repo_dir] |
64 |
+ finally: |
65 |
+ cls.envlock.release() |
66 |
+ |
67 |
+ return ret |
68 |
+ |
69 |
+ |
70 |
def __init__ ( self ): |
71 |
super ( ExternalManifestCreation, self ) . __init__ () |
72 |
- self.manifest_env = ManifestEnv ( filter_env=True ) |
73 |
# ebuild <ebuild_file> <target>, where target is: |
74 |
self.ebuild_tgt = config.get ( 'TOOLS.EBUILD.target', 'manifest' ) |
75 |
self.ebuild_prog = config.get ( 'TOOLS.EBUILD.prog', '/usr/bin/ebuild' ) |
76 |
@@ -60,7 +71,7 @@ class ExternalManifestCreation ( _ManifestCreation ): |
77 |
raises: *passes Exceptions from failed config lookups |
78 |
""" |
79 |
|
80 |
- my_env = self.manifest_env [ package_info ['distdir'] ] |
81 |
+ my_env = self.__class__.get_env ( package_info ['distdir'] ) |
82 |
|
83 |
ebuild_file = package_info ['ebuild_file'] |