tarscloud / tarstup Goto Github PK
View Code? Open in Web Editor NEWTars tup protocol
License: BSD 3-Clause "New" or "Revised" License
Tars tup protocol
License: BSD 3-Clause "New" or "Revised" License
When tcp connection failed and get EPOLLERR/ EPOLLHUP events, sync invoke doesn't return immediately. Instead, it waits until timeout and return.
tup-python
Traceback (most recent call last):
File "Hello.py", line 1, in
from tars.core import tarscore;
File "/data/home/maypeng/tup-python/tup-python/tars/core.py", line 89, in
from __rpc import Communicator
File "/data/home/maypeng/tup-python/tup-python/tars/__rpc.py", line 35, in
from __adapterproxy import AdapterProxyManager
File "/data/home/maypeng/tup-python/tup-python/tars/__adapterproxy.py", line 25, in
from enum import Enum
ImportError: No module named enum
我这边想定义一个64位的整型,发现尝试了很多都没有成功。想看看哪里有支持的类型列表。
If you find any dependent libraries in code but never display its open source license in the License file, please comment on this issue, We will update the License file ASAP.
You also can pull request to the License file and remember to describe in detail ; )
Welcome to contribute!
I cannot find TarsTup for java.It looks like do not support java at present.When will it support java?
void JString_copy(char * dest, const char * src, uint32_t len)
{
char * pe = dest + len;
if (dest == NULL || src == NULL || (Int32)len < 0)
return;
if (dest < src)
{
for (; dest != pe; ++dest, ++src)
*dest = *src;
}
else if (dest > src) //fix bug:not cosider dest and src overlapping
{
char* pe = (char*)dest + len - 1;
const char* ps = (const char*)src + len - 1;
while(len-- > 0)
{
*pe-- = *ps--;
}
}
}
C#版本的 生成工具在哪里!
在jceinputStream.m里的, 各种断言,建议改成抛错处理,至少程序不会崩溃
例如 msg = b'\x02\x00\x0b\xf4\x8d'
解析成 {0: 783501, 1: 'xxx'}
tup-oc的example缺挺多.h,.m啊,是还有另外的pod库吗?有没有使用的说明。。。
TarsTup/tup-python/tars/__servantproxy.py
Line 281 in fd2cb8a
in some case, network thread send req and received rsp before this wait call, then reqmsg.lock.wait(self.__timeout()) will block for self.__timeout() seconds
in tup-python:
TimeoutQueue::timeout has a bug that only clears timeout request in __data, but doesn't clear the correspond uniqId in __queue.
Then for TimeoutQueue::pop, may occur that uniqId is already timeout and correspond reqmsg in __data has been cleared. So for code "ret = self.__data.get(uniqId, None)", ret will be None, and TimeoutQueue::pop will return None too.
`
def pop(self, uniqId=0, erase=True):
'''
@brief: 弹出item
@param uniqId: item的id,如果为0,按FIFO弹出
@type uniqId: int
@param erase: 弹出后是否从字典里删除item
@type erase: bool
@return: item
@rtype: any type
'''
ret = None
# self.__lock.acquire()
lock = LockGuard(self.__lock)
if not uniqId:
if len(self.__queue):
uniqId = self.__queue.pop(0)
if uniqId:
if erase:
ret = self.__data.pop(uniqId, None)
else:
ret = self.__data.get(uniqId, None)
# self.__lock.release()
return ret[0] if ret else None
def timeout(self):
'''
@brief: 检测是否有item超时,如果有就删除
@return: None
@rtype: None
'''
endtime = time.time()
# self.__lock.acquire()
lock = LockGuard(self.__lock)
# 处理异常情况,防止死锁
try:
new_data = {}
for uniqId, item in self.__data.iteritems():
if endtime - item[1] < self.__timeout:
new_data[uniqId] = item
else:
tarsLogger.debug(
'TimeoutQueue:timeout remove id : %d' % uniqId)
self.__data = new_data
finally:
# self.__lock.release()
pass
`
The implementation of NewLock is incorrect. When one thread has get lock, the another thread can't be blocked by it for the incorrect use of __count in newAcquire. The __count shoud use thread local storage and there is no need for __lockForCount.
We can also use RLock to get reentrant mutex lock function.
`
class NewLock(object):
def init(self):
self.__count = 0
self.__lock = Lock()
self.__lockForCount = Lock()
pass
def newAcquire(self):
self.__lockForCount.acquire()
self.__count += 1
if self.__count == 1:
self.__lock.acquire()
self.__lockForCount.release()
pass
`
__tars.py 中,在解码时运行到value=coder.readfrom(self)时报错
def __readStruct(self, coder, tag, require, default=None):
if self.__skipToTag(tag):
t, p, l = self.__readFrom()
if p != DataHead.EN_STRUCTBEGIN:
raise TarsTarsDecodeMismatch(
"read 'struct' type mismatch, tag: %d, get type: %d." % (tag, p))
value = coder.readFrom(self)
self.__skipToStructEnd()
return value
elif require:
raise TarsTarsDecodeRequireNotExist(
"require field not exist, tag: %d" % tag)
return default
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.