Code Monkey home page Code Monkey logo

Comments (6)

hmilymb avatar hmilymb commented on July 30, 2024

i print the time

    def push_transaction(self, transaction, keys, broadcast=True, compression='none') :
        ''' '''
        t0 = time.time()
        chain_info,lib_info = self.get_chain_lib_info()
        t1 = time.time()
        trx = Transaction(transaction, chain_info, lib_info)
        t2 = time.time()
        #encoded = trx.encode()
        digest = sig_digest(trx.encode(), chain_info['chain_id'])
        t3 = time.time()
        # sign the transaction
        signatures = []
        if not isinstance(keys, list) :
            keys = [keys]
        for key in keys :
            if check_wif(key) :
                k = EOSKey(key)
            elif isinstance(key, EOSKey) :
                k = key
            else :
                raise ValueError('Must pass a WIF string or EOSKey')
            signatures.append(k.sign(digest))
        # build final trx

        final_trx = {
                'compression' : compression,
                'transaction' : trx.__dict__,
                'signatures' : signatures
        }
        data = json.dumps(final_trx, cls=EOSEncoder)
        if broadcast :
            t4 = time.time()
            ret = self.post('chain.push_transaction', params=None, data=data)
            t5 = time.time()
            logger.info("testpush pyeos push transaction t1 %f %f %f %f %f  " % (t5-t4, t4-t3, t3-t2, t2-t2, t1-t0))
            return ret
        return data


2018-10-22 14:33:33,628 cron [reveal3.py:207] [reveal3:reveal] [INFO]- testpush pyeos push transaction t1 0.262906 0.680234 0.000355 0.000000 0.618895
2018-10-22 14:33:33,628 cron [reveal3.py:209] [reveal3:reveal] [INFO]- testpush t1 0.505181 t2 1.563141, len 1 ,https://node.betdice.one
2018-10-22 14:33:36,860 cron [reveal3.py:241] [reveal3:clean] [INFO]- testpush pyeos push transaction t1 0.272354 0.746254 0.000295 0.000000 0.627473
2018-10-22 14:33:41,592 cron [reveal3.py:207] [reveal3:reveal] [INFO]- testpush pyeos push transaction t1 0.810577 0.754046 0.000304 0.000000 0.635905
2018-10-22 14:33:41,592 cron [reveal3.py:209] [reveal3:reveal] [INFO]- testpush t1 0.266842 t2 2.201648, len 1 ,https://node.betdice.one
2018-10-22 14:33:44,992 cron [reveal3.py:241] [reveal3:clean] [INFO]- testpush pyeos push transaction t1 0.409997 0.534914 0.000298 0.000000 0.724628
2018-10-22 14:33:49,904 cron [reveal3.py:207] [reveal3:reveal] [INFO]- testpush pyeos push transaction t1 0.440897 0.419582 0.000298 0.000000 1.158752
2018-10-22 14:33:49,904 cron [reveal3.py:209] [reveal3:reveal] [INFO]- testpush t1 0.623600 t2 2.020310, len 1 ,https://node.betdice.one
2018-10-22 14:33:55,501 cron [reveal3.py:241] [reveal3:clean] [INFO]- testpush pyeos push transaction t1 0.373271 0.690031 0.000309 0.000000 0.523841
2018-10-22 14:34:00,016 cron [reveal3.py:207] [reveal3:reveal] [INFO]- testpush pyeos push transaction t1 0.253978 0.430541 0.000308 0.000000 2.890502
2018-10-22 14:34:00,017 cron [reveal3.py:209] [reveal3:reveal] [INFO]- testpush t1 0.275315 t2 3.576005, len 1 ,https://node.betdice.one
2018-10-22 14:34:04,197 cron [reveal3.py:241] [reveal3:clean] [INFO]- testpush pyeos push transaction t1 0.256069 1.133181 0.000297 0.000000 0.940432
2018-10-22 14:34:10,392 cron [reveal3.py:207] [reveal3:reveal] [INFO]- testpush pyeos push transaction t1 0.950557 0.847115 0.000306 0.000000 0.662502
2018-10-22 14:34:10,392 cron [reveal3.py:209] [reveal3:reveal] [INFO]- testpush t1 0.361795 t2 2.461179, len 1 ,https://node.betdice.one
2018-10-22 14:34:12,926 cron [reveal3.py:241] [reveal3:clean] [INFO]- testpush pyeos push transaction t1 0.277198 0.678810 0.000309 0.000000 0.577521
2018-10-22 14:34:17,796 cron [reveal3.py:207] [reveal3:reveal] [INFO]- testpush pyeos push transaction t1 0.385666 0.598964 0.000309 0.000000 0.660867
2018-10-22 14:34:17,797 cron [reveal3.py:209] [reveal3:reveal] [INFO]- testpush t1 0.292558 t2 1.646578, len 1 ,https://node.betdice.one
2018-10-22 14:34:21,999 cron [reveal3.py:241] [reveal3:clean] [INFO]- testpush pyeos push transaction t1 0.288089 0.622102 0.000298 0.000000 0.882234
2018-10-22 14:49:34,480 cron [reveal3.py:207] [reveal3:reveal] [INFO]- testpush pyeos push transaction t1 0.254058 0.972861 0.000308 0.000000 0.738683
2018-10-22 14:49:34,480 cron [reveal3.py:209] [reveal3:reveal] [INFO]- testpush t1 0.297338 t2 1.966620, len 1 ,https://node.betdice.one
2018-10-22 14:49:38,315 cron [reveal3.py:241] [reveal3:clean] [INFO]- testpush pyeos push transaction t1 0.386651 0.762413 0.000289 0.000000 0.654372
2018-10-22 14:55:51,221 cron [reveal3.py:207] [reveal3:reveal] [INFO]- testpush pyeos push transaction t1 0.259884 0.719956 0.000316 0.000000 0.732728
2018-10-22 14:55:51,221 cron [reveal3.py:209] [reveal3:reveal] [INFO]- testpush t1 0.392273 t2 1.713637, len 1 ,https://node.betdice.one
2018-10-22 14:55:55,153 cron [reveal3.py:241] [reveal3:clean] [INFO]- testpush pyeos push transaction t1 0.234202 0.430292 0.000320 0.000000 0.804622

from eospy.

deckb avatar deckb commented on July 30, 2024

I will take a look to see what the issue could be. There of course could be many issues here but let me see if we can make it quicker for you.

from eospy.

hmilymb avatar hmilymb commented on July 30, 2024

thank you for you help。
it maybe network delay, http://172.31.129.125:8888 is other host,my localhost ip is faster 。

215         t1 = time.time()
216         for bet in bet_list:
217             betid = bet['id']
218             server_seed = bet['server_seed']
219             act = make_push_data(ce, from_, betid, server_seed)
220             actions.append(act)
221
224         trx = {"actions": actions}
226         t2 = time.time()
227         resp = ce.push_transaction(trx, key, broadcast=True)
228         t3 = time.time()
229         logger.info("testpush t1 %f t2 %f, len %d ,%s " % (t2-t1, t3-t2, len(bet_list), consts.chain_url))

2270 2018-10-23 16:05:09,342 cron [reveal3.py:230] [reveal3:reveal] [INFO]- testpush t1 0.020123 t2 0.685841, len 1 ,http://127.0.0.1:8888

from eospy.

hmilymb avatar hmilymb commented on July 30, 2024

but i had other problem, post data hanging
on resp = ce.push_transaction(trx, key, broadcast=True)

● update_open.service - gunicorn daemon
   Loaded: loaded (/etc/systemd/system/update_open.service; disabled; vendor preset: enabled)
   Active: active (running) since Wed 2018-10-24 00:08:58 CST; 45min ago
 Main PID: 3581 (python3)
    Tasks: 1
   Memory: 45.1M
      CPU: 51.803s
   CGroup: /system.slice/update_open.service
           └─3581 /home/nb/virtualenv/bin/python3 shell/update_open.py > /dev/null 2>&1 &

Oct 24 00:12:35 iZj6c5tuedcseyv7tmwgdcZ python3[3581]: get game account  xxx
Oct 24 00:12:35 iZj6c5tuedcseyv7tmwgdcZ python3[3581]: get game account  xxx
Oct 24 00:12:35 iZj6c5tuedcseyv7tmwgdcZ python3[3581]: get game account  xxx
Oct 24 00:12:35 iZj6c5tuedcseyv7tmwgdcZ python3[3581]: get game account  xxx
Oct 24 00:12:35 iZj6c5tuedcseyv7tmwgdcZ python3[3581]: get game account  xxx
Oct 24 00:12:35 iZj6c5tuedcseyv7tmwgdcZ python3[3581]: get reveal account  xxx
Oct 24 00:12:35 iZj6c5tuedcseyv7tmwgdcZ python3[3581]: account push  xxx
Oct 24 00:12:35 iZj6c5tuedcseyv7tmwgdcZ python3[3581]: push  {'transaction_id': 'c74dcd691a1951cb717ea5b8c8d9b70341159ba954feb2c8f5efbe9e9f5e70c7',
Oct 24 00:12:35 iZj6c5tuedcseyv7tmwgdcZ python3[3581]: st': '5430b24a80e720d46bfdc2d24c1f9cba3ca82ab430a31db35566954bcef3fc02', 'global_sequence':
Oct 24 00:12:35 iZj6c5tuedcseyv7tmwgdcZ python3[3581]: ization': [{'actor': 'xxx', 'permission': 'active'}], 'data': {'from': 'xxx
root@iZj6c5tuedcseyv7tmwgdcZ:~# strace -p 3581
strace: Process 3581 attached
recvfrom(17,

and i think it maybe because of eospy no set requests timeout 。
http://docs.python-requests.org/en/master/user/quickstart/#timeouts
i added timeout and no hanging again


    def get_url(self, url, params=None, json=None) :
        # get request
        r = requests.get(url,params=params, json=json, timeout=4)
        r.raise_for_status()
        return r.json()

    def post_url(self, url, params=None, json=None, data=None) :
        # post request
        r = requests.post(url,params=params, json=json, data=data, timeout=4)
        try :
            r.raise_for_status()
        except :
            raise requests.exceptions.HTTPError('Error: {}'.format(r.json()))
        return r.json()

from eospy.

deckb avatar deckb commented on July 30, 2024

I have added a timeout option for all the functions. Thank you for your information regarding this issue.

from eospy.

hmilymb avatar hmilymb commented on July 30, 2024

thank you 。。

from eospy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.