def write(self, d): assert isinstance(d, dict) with phlsys_fs.write_file_lock_context(self._filename) as f: f.write(json.dumps(d))
# append our module dirs to sys.path, which is the list of paths to search # for modules this is so we can import our libraries directly # N.B. this magic is only really passable up-front in the entrypoint module PARENT_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) BASE_DIR = os.path.dirname(PARENT_DIR) sys.path.append(os.path.join(BASE_DIR, "py", "phl")) import phlsys_fs while True: d = {} for i in xrange(0, random.randint(1, 1000)): d[i] = random.randint(1, 1000) with phlsys_fs.write_file_lock_context('test-file') as f: f.write(json.dumps(d)) # print ".", # ----------------------------------------------------------------------------- # Copyright (C) 2013-2014 Bloomberg Finance L.P. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# append our module dirs to sys.path, which is the list of paths to search # for modules this is so we can import our libraries directly # N.B. this magic is only really passable up-front in the entrypoint module PARENT_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) BASE_DIR = os.path.dirname(PARENT_DIR) sys.path.append(os.path.join(BASE_DIR, "py", "phl")) import phlsys_fs while True: d = {} for i in xrange(0, random.randint(1, 1000)): d[i] = random.randint(1, 1000) with phlsys_fs.write_file_lock_context("test-file") as f: f.write(json.dumps(d)) # print ".", # ----------------------------------------------------------------------------- # Copyright (C) 2013-2014 Bloomberg Finance L.P. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software.