How to use tblib - 10 common examples

To help you get started, we’ve selected a few tblib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github browsertron / pytest-parallel / pytest_parallel / View on Github external
def run(self):
        while True:
                index = self.queue.get()
                if index == 'stop':
            except ConnectionRefusedError:
            item = self.session.items[index]
                run_test(self.session, item, None)
            except BaseException:
                import pickle
                import sys
github standy66 / purerpc / src / purerpc / View on Github external
import multiprocessing
import multiprocessing.connection
import tempfile
import shutil
import os
import sys
import inspect
import importlib
import concurrent.futures
import contextlib
import time
import random
import string

from tblib import pickling_support

import forge
import anyio
from async_generator import aclosing

def compile_temp_proto(*relative_proto_paths):
    modules = []
    with tempfile.TemporaryDirectory() as temp_dir:
        sys.path.insert(0, temp_dir)
            for relative_proto_path in relative_proto_paths:
                proto_path = os.path.join(os.path.dirname(
github Shopify / ci-queue / python / ciqueue / _pytest / View on Github external
be put them on the redis queue. Then, we swap back in the original exception
when reading off the queue. These operations are performed by
`swap_in_serializable` and `swap_back_original`, respectively.

from __future__ import absolute_import
import dill
    from _pytest import outcomes
except ImportError:
    from _pytest import runner as outcomes
from _pytest._code import code
from tblib import pickling_support


class Skipped(Exception):
    """placeholder for outcomes.Skipped which is not serializable"""

class Failed(Exception):
    """placeholder for outcomes.Failed which is not serializable"""

class UnserializableException(Exception):
    """placeholder for any Exceptions that cannnot be serialized"""

SERIALIZE_TYPES = {outcomes.Skipped: Skipped,
                   outcomes.Failed: Failed}
github OpenNebula / one / src / oca / python / pyone / View on Github external
# limitations under the License.

from hashlib import md5
from json import load, dumps as json_dumps
from base64 import b64decode, b64encode
from pickle import dumps, loads
from os import path
from . import OneServer
from tblib import pickling_support
from sys import exc_info
from six import reraise
from collections import OrderedDict
from gzip import open
from os import environ


def read_fixture_file(fixture_file):
    f = open(fixture_file, "rt")
    ret = load(f)
    return ret

def write_fixture_file(fixture_file, obj):
    f = open(fixture_file, "wb")

class OneServerTester(OneServer):
github martinsmid / pytest-ui / pytui / View on Github external
            Set test result in internal dictionary. Updates UI.

                test_id: An unique string test identifier.
        update_listbox = False

        if not test_id in self.test_data:
            self.test_data[test_id] = {
                'id': test_id
            update_listbox = True

        if extracted_traceback:
            py_traceback = Traceback.from_dict(extracted_traceback).as_traceback()
            extracted_traceback = traceback.extract_tb(py_traceback)
            output += ''.join(
                traceback.format_list(extracted_traceback) +

        test_data = self.test_data[test_id]
        test_data['exc_type'] = exc_type
        test_data['exc_value'] = exc_value
        test_data['exc_tb'] = extracted_traceback
        if when == 'call' and last_failed_exempt is not None:
            test_data['last_failed_exempt'] = last_failed_exempt

        # Ignore success, except for the 'call' step
        # ignore successive failure, take only the first
        if (outcome != 'passed' or when == 'call') \
github shiyanlou / louplus-python / taobei / tbuser / handlers / View on Github external

    ids = []
    for v in request.args.get('ids', '').split(','):
        id = int(v.strip())
        if id > 0:
    if len(ids) == 0:
        raise BadRequest()

    query = Address.query.filter(

    addresses = { AddressSchema().dump(address)
                 for address in query}

    return json_response(addresses=addresses)
github shiyanlou / louplus-python / taobei / tbbuy / handlers / View on Github external
def delete_cart_product(id):

    cart_product = CartProduct.query.filter( == id).first()
    if cart_product is None:
        return json_response(ResponseCode.NOT_FOUND)


    return json_response(cart_product=CartProductSchema().dump(cart_product))
github shiyanlou / louplus-python / taobei / tbbuy / handlers / View on Github external

    user_id = request.args.get('user_id', type=int)
    order_direction = request.args.get('order_direction', 'desc')
    limit = request.args.get(
        'limit', current_app.config['PAGINATION_PER_PAGE'], type=int)
    offset = request.args.get('offset', 0, type=int)

    order_by = if order_direction == 'asc' else
    query = Order.query
    if user_id is not None:
        query = query.filter(Order.user_id == user_id)
    total = query.count()
    query = query.order_by(order_by).limit(limit).offset(offset)

    return json_response(orders=OrderSchema().dump(query, many=True), total=total)
github shiyanlou / louplus-python / taobei / challenge-02 / tbmall / handlers / View on Github external
def update_product(id):

    data = request.get_json()

    count = Product.query.filter( == id).update(data)
    if count == 0:
        return json_response(ResponseCode.NOT_FOUND)
    product = Product.query.get(id)

    return json_response(product=ProductSchema().dump(product))