Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions openprocurement/bridge/basic/databridge.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# -*- coding: utf-8 -*-
from gevent import monkey
monkey.patch_all()
from openprocurement.bridge.basic.monkey import patch_traceback
patch_traceback()
#

import argparse
import logging
Expand All @@ -19,7 +22,7 @@
from openprocurement_client.resources.sync import ResourceFeeder
from openprocurement_client.resources.tenders import TendersClient as APIClient
from pkg_resources import iter_entry_points
from yaml import load
from yaml import safe_load

from openprocurement.bridge.basic.constants import DEFAULTS, PROCUREMENT_METHOD_TYPE_HANDLERS
from openprocurement.bridge.basic.utils import DataBridgeConfigError
Expand Down Expand Up @@ -110,7 +113,7 @@ def __init__(self, config):
for entry_point in iter_entry_points('openprocurement.bridge.basic.worker_plugins', self.worker_type):
self.worker_greenlet = entry_point.load()

self.feeder = ResourceFeeder(host=self.api_host,
self.feeder = ResourceFeeder(host=self.config.get('public_resources_api_server', self.api_host),
version=self.api_version, key='',
resource=self.config['resource'],
extra_params=self.extra_params,
Expand Down Expand Up @@ -363,7 +366,7 @@ def main():
params = parser.parse_args()
if os.path.isfile(params.config):
with open(params.config) as config_file_obj:
config = load(config_file_obj.read())
config = safe_load(config_file_obj.read())
logging.config.dictConfig(config)
BasicDataBridge(config).run()

Expand Down
21 changes: 21 additions & 0 deletions openprocurement/bridge/basic/monkey.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import traceback
import logging

exception_logger = logging.getLogger('exception_logger')


def print_exception(etype, value, tb, **kwargs):
'''
Monkey patching for handle Greenlets exception (gevent.hub.Hub#handle_error)
'''
try:
exception_logger.error(''.join(traceback.format_exception(etype, value, tb)))
except Exception as e:
exception_logger.error('Exception logging error: {}'.format(repr(e)))
return traceback.original_print_exception(etype, value, tb, **kwargs)


def patch_traceback():
traceback.original_print_exception = traceback.print_exception
traceback.print_exception = print_exception

4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import os

version = '0.1.1'
version = '0.1.4dp'

here = os.path.abspath(os.path.dirname(__file__))

Expand Down Expand Up @@ -72,7 +72,7 @@
url="https://github.com/openprocurement/",
license='Apache License 2.0',
packages=find_packages(exclude=['ez_setup']),
namespace_packages=['openprocurement'],
namespace_packages=['openprocurement', 'openprocurement.bridge'],
include_package_data=True,
zip_safe=False,
install_requires=requires,
Expand Down