예제 #1
0
 def save_day(iterable, fname, mode='w'):
     full_data_len = 0
     with open(fname, mode) as fout:
         for obj in iterable:
             try:
                 data = FileProtocol.dumps(obj) + '\n'
             except TypeError:
                 raise Exception(
                     "Object can't be serialized: %s" % repr(obj)
                 )
             fout.write(data)
             full_data_len += len(data)
     multiprocessing.get_logger().info(
         "daily_over_fs: wrote %d characters to %s" % (
             full_data_len, fname
         )
     )
예제 #2
0
 def load_day(fname):
     with open(fname) as fin:
         for line in fin:
             yield FileProtocol.loads(line)