Skip to content
This repository has been archived by the owner on Dec 24, 2020. It is now read-only.

decoding int error. #72

Open
navneeth opened this issue May 13, 2019 · 6 comments
Open

decoding int error. #72

navneeth opened this issue May 13, 2019 · 6 comments

Comments

@navneeth
Copy link

[2019-05-13 14:55:29,204] ERROR in app: Exception on /v1/datas [GET]
Traceback (most recent call last):
File "/Curve/venv/lib/python3.5/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/Curve/venv/lib/python3.5/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functionsrule.endpoint
File "/Curve/venv/lib/python3.5/site-packages/flask_restful/init.py", line 458, in wrapper
resp = resource(*args, **kwargs)
File "/Curve/venv/lib/python3.5/site-packages/flask/views.py", line 88, in view
return self.dispatch_request(*args, **kwargs)
File "/Curve/venv/lib/python3.5/site-packages/flask_restful/init.py", line 573, in dispatch_request
resp = meth(*args, **kwargs)
File "/Curve/api/curve/v1/validators.py", line 115, in wrapper
resp = view(*args, **kwargs)
File "/Curve/api/curve/v1/validators.py", line 106, in wrapper
return view(*args, **kwargs)
File "/Curve/api/curve/v1/api/datas.py", line 35, in get
return self.render(data=[data.view() for data in datas])
File "/Curve/api/curve/v1/api/datas.py", line 35, in
return self.render(data=[data.view() for data in datas])
File "/Curve/api/curve/v1/models/data_abstract.py", line 61, in view
'end': min(self.start_time + 86400, self.end_time) * 1000
TypeError: can't concat bytes to int`

After fixing many errors in the last PR. This is the error that has me stumped.
Looks like the start_time is not being decoded into an int properly. Please assist with pointers

@minorcong
Copy link
Collaborator

The start_time should be int according to https://github.com/baidu/Curve/blob/master/api/curve/v1/models/data_abstract.py#L29, Maybe it's helpful to run in debug mode, stop curve(free the port 8080) and debug api/profile.py

@navneeth
Copy link
Author

navneeth commented May 13, 2019

The upload file is the example used here: https://github.com/baidu/Curve.

./control.sh start; tail -f api/log/*.log

Results in

local Curve version: 2321498
start Curve...
[uWSGI] getting INI configuration from uwsgi.ini
Curve started.
detected binary path: /Curve/venv/bin/uwsgi
chdir() to .
your processes number limit is 773188
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on 0.0.0.0:8080 fd 4
uwsgi socket 0 bound to TCP address 127.0.0.1:41923 (port auto-assigned) fd 3
Python version: 3.5.2 (default, Nov 12 2018, 13:43:14) [GCC 5.4.0 20160609]
Python main interpreter initialized at 0x970a40
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 656928 bytes (641 KB) for 8 cores
*** Operational MODE: preforking+threaded ***
added ../venv/lib/python2.7/site-packages to pythonpath.
WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x970a40 pid: 3230 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 3230)
spawned uWSGI worker 1 (pid: 3272, cores: 4)
spawned uWSGI worker 2 (pid: 3273, cores: 4)
*** Stats server enabled on 127.0.0.1:9191 fd: 15 ***
spawned uWSGI http 1 (pid: 3277)
[pid: 3273|app: 0|req: 1/1] 172.29.51.214 () {38 vars in 705 bytes} [Mon May 13 15:24:34 2019] GET / => generated 237 bytes in 8 msecs (HTTP/1.1 302) 4 headers in 166 bytes (1 switches on core 0)
[2019-05-13 15:24:35,137] ERROR in app: Exception on /v1/datas [GET]
Traceback (most recent call last):
File "/Curve/venv/lib/python3.5/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/Curve/venv/lib/python3.5/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functionsrule.endpoint
File "/Curve/venv/lib/python3.5/site-packages/flask_restful/init.py", line 458, in wrapper
resp = resource(*args, **kwargs)
File "/Curve/venv/lib/python3.5/site-packages/flask/views.py", line 88, in view
return self.dispatch_request(*args, **kwargs)
File "/Curve/venv/lib/python3.5/site-packages/flask_restful/init.py", line 573, in dispatch_request
resp = meth(*args, **kwargs)
File "/Curve/api/curve/v1/validators.py", line 153, in wrapper
json.dumps(resp, cls=JSONEncoder) + '\n',
File "/Curve/venv/lib/python3.5/site-packages/flask/json/init.py", line 179, in dumps
rv = _json.dumps(obj, **kwargs)
File "/usr/lib/python3.5/json/init.py", line 237, in dumps
**kw).encode(obj)
File "/usr/lib/python3.5/json/encoder.py", line 198, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.5/json/encoder.py", line 256, in iterencode
return _iterencode(o, 0)
File "/home/navneeth/Curve/api/curve/v1/validators.py", line 31, in default
return json.JSONEncoder.default(self, o)
File "/Curve/venv/lib/python3.5/site-packages/flask/json/init.py", line 81, in default
return _json.JSONEncoder.default(self, o)
File "/usr/lib/python3.5/json/encoder.py", line 179, in default
raise TypeError(repr(o) + " is not JSON serializable")

@navneeth
Copy link
Author

@minorcong I appreciate if you can tell me how to invoke the code in pdb.
I am new to flask/ node.js.
Just discovered that uwsgi frameworks map stderr/stdout to null. So that putting an
import pdb; pdb.set_trace
does not trigger a debug prompt.
How do you recommend ?

@minorcong
Copy link
Collaborator

The application entry point is api/uwsgi.py. This maybe helpful https://github.com/baidu/Curve/blob/master/api/profile.py#L16

@navneeth
Copy link
Author

@minorcong. I downgraded to python2.7 & the issue is fixed now.
Please correct the information in your README.md.

Dependency:
Python 2.7.3+/3.1.2+, if python is not owned by current user, virtualenv is required

Python > 3 does not seem to be supported as of now.

Thank you for your help & an excellent code-base. I hope to submit a few more PR's in future.

@minorcong minorcong reopened this May 14, 2019
@minorcong
Copy link
Collaborator

@navneeth I'm sorry for this. Curve is designed to be Python 2/3 compatible and developed in Python 2.7.3, Python 2.7.15 and python 3.1.2, but the compatibility testing of latest version seems not insufficient, eg. request lib, click lib ...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants