Revert "Revert "oran-shell-release: release image for F""
[pti/rtp.git] / meta-starlingx / meta-stx-cloud / recipes-devtools / python / files / python-keyring / lock_keyring_file.patch
1 Index: keyring-5.3/keyring/backends/file.py
2 ===================================================================
3 --- keyring-5.3.orig/keyring/backends/file.py
4 +++ keyring-5.3/keyring/backends/file.py
5 @@ -6,6 +6,7 @@ import base64
6  import sys
7  import json
8  import abc
9 +import time
10  
11  from ..py27compat import configparser
12  
13 @@ -95,14 +96,29 @@ class BaseKeyring(FileBacked, KeyringBac
14          config = configparser.RawConfigParser()
15          config.read(self.file_path)
16  
17 +        # obtain lock for the keyring file
18 +        lock = ''
19 +        i = 60
20 +        while i:
21 +            if not os.path.isfile('/tmp/.keyringlock'):
22 +                lock = open('/tmp/.keyringlock', 'w')
23 +                break
24 +            else:
25 +                time.sleep(0.500)
26 +                i=i-1
27 +
28          # update the keyring with the password
29          if not config.has_section(service):
30              config.add_section(service)
31          config.set(service, username, password_base64)
32  
33 -        # save the keyring back to the file
34 -        with open(self.file_path, 'w') as config_file:
35 -            config.write(config_file)
36 +        if i:
37 +            # save the keyring back to the file
38 +            with open(self.file_path, 'w') as config_file:
39 +                config.write(config_file)
40 +            lock.close()
41 +            os.remove('/tmp/.keyringlock')
42 +
43  
44      def _ensure_file_path(self):
45          """