*Session attributes handling enhancement and TcpSocketSession cleanup#116
Conversation
|
@MatthieuDartiailh code tested and ready for final review |
|
I may need some time to review this. Hopefully I will merge sometimes next week. |
MatthieuDartiailh
left a comment
There was a problem hiding this comment.
Overall this looks really good. I left some minor comments. I will try to make a more thorough review later.
| @@ -181,7 +184,8 @@ def __init__(self, resource_manager_session, resource_name, parsed=None, open_ti | |||
| self.attrs = {constants.VI_ATTR_RM_SESSION: resource_manager_session, | |||
There was a problem hiding this comment.
Could you expand the above description to detail the possible values in the dictionary ?
There was a problem hiding this comment.
Comment added into after_parsing method of Session
| # therefore we must handle the case that the termination character is in the middle of the block | ||
| # or that the maximum number of bytes is exceeded | ||
| timeout = self.get_attribute(constants.VI_ATTR_TMO_VALUE)[0] / 1000. | ||
| timeout, _ = self.get_attribute(constants.VI_ATTR_TMO_VALUE) |
There was a problem hiding this comment.
Why split this on two lines ?
There was a problem hiding this comment.
Unified form of reading timeout in all *Session object
But now I seethis shall be changed to use `self.timeout, it is now properly filled containing python way of timeout (seconds + None) so can be used directly without double conversion.
|
|
||
| ret_status = self._connect() | ||
| if ret_status != constants.StatusCode.success: | ||
| if ret_status != SUCCESS: |
There was a problem hiding this comment.
This is unification of return codes in this file with previous implementation, when SUCCESS was used, one way shall be followed, so which of these 3 options (see line 25 and 26 of this file):
SUCCESStatusCode.successconstants.StatusCode.success
it is related other return codes in the file, when second form is used.
|
One stupid question: shouldn't |
|
Further changes / fixes in timeout handling added, some comments applied). Regarding How to cope with the |
|
@MatthieuDartiailh #118 have to be resolved (merged or closed) before this issue (in conflict) |
| return bytes(out[:count]), constants.StatusCode.success_max_count_read | ||
| if term_char_en and term_byte in self._pending_buffer: | ||
| term_byte_index = self._pending_buffer.index(term_byte) + 1 | ||
| if term_byte_index > count: |
There was a problem hiding this comment.
this check improves handling of case when requested less data then recevied and also terchar received. (#101)
# Conflicts resolved manualy: # pyvisa-py/sessions.py # pyvisa-py/tcpip.py
MatthieuDartiailh
left a comment
There was a problem hiding this comment.
I believe that one comment is wrong but apart from this this is good to go for me.
| TIMETABLE = (0, 1e-2, 3e-2, 1e-1, 3e-1, 1e0, 3e0, 1e1, 3e1, 1e2, 3e2, 1e3, 3e3, | ||
| 1e4, 3e4, 1e5, 3e5, 1e6) | ||
|
|
||
| # linux-gpib timeout constants, in milliseconds. See GPIBSession._set_timeout. |
There was a problem hiding this comment.
Those numbers are in second now no ?
There was a problem hiding this comment.
yes, i forgot to change comment properly
|
Merging. Thanks again @skrchnavy bors r+ |
116: *Session attributes handling enhancement and TcpSocketSession cleanup r=MatthieuDartiailh a=skrchnavy * `Session.attrs` table enhanced to support getter and setter methods, not only values * `VI_ATTR_TMO_VALUE` attribute handling unified to setup also self.timeout as value holder (can be used in sessions and is set to 'python' timeout - seconds as float or None for infinite) * `_get_timeout`/`_set_timeout` methods added and updated for places where external lib timeout is setup. * GPIBInstrSessiontimeout handling corrected (tested without HW if correct value is calculated in different conditions) * TCPIP Socket Session supports additional attributes (were not implemented) * `Session.attrs` table used for implementation with getters and setters * code cleanup to remove class attributes and use instance attributes * `_pending_buffer` is main buffer for handling received data, removed copying from temp buffer (`out`) and pending buffer
Build succeeded |
Session.attrstable enhanced to support getter and setter methods, not only valuesVI_ATTR_TMO_VALUEattribute handling unified to setup also self.timeout as value holder (can be used in sessions and is set to 'python' timeout - seconds as float or None for infinite)_get_timeout/_set_timeoutmethods added and updated for places where external lib timeout is setup.Session.attrstable used for implementation with getters and setters_pending_bufferis main buffer for handling received data, removed copying from temp buffer (out) and pending buffer