Skip to content

Commit

Permalink
remove print_status
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffkaufman committed Feb 7, 2021
1 parent 023fe19 commit b218a77
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 33 deletions.
22 changes: 0 additions & 22 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ def reset(self):

self.max_position = DELAY_INTERVAL*LAYERING_DEPTH

self.last_status_ts = 0.0

self.disable_auto_gain = False
self.disable_song_video = False

Expand Down Expand Up @@ -1214,30 +1212,10 @@ def handle_post(in_json, in_data) -> Tuple[Any, str]:
x_audio_metadata.update(user.to_send)
user.mark_sent()

if in_json.get("print_status", False):
maybe_print_status()

bin_summary = binary_user_summary(user_summary(requested_user_summary))
if len(bin_summary) > 0:
data = np.append(bin_summary, data.view(dtype=np.uint8))
return data, json.dumps(x_audio_metadata)

def maybe_print_status() -> None:
now = time.time()
if now - state.last_status_ts < STATUS_PRINT_INTERVAL_S:
return

print("-"*70)

for delay, name, mic_volume, userid, \
rms_volume, muted in user_summary(requested_user_summary=True):
print ("%s %s vol=%.2f rms=%.5f" % (
str(delay).rjust(3),
name.rjust(30),
mic_volume,
rms_volume))

state.last_status_ts = now

if __name__ == "__main__":
print("Run server_wrapper.py or shm.py instead")
12 changes: 5 additions & 7 deletions server_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ def unpack_multi(data) -> List[Any]:
def calculate_volume(in_data):
return np.sqrt(np.mean(in_data**2))

def handle_post_special(query_string, print_status=True):
data, x_audio_metadata = handle_json_post(np.zeros(0), query_string, {}, print_status)
def handle_post_special(query_string):
data, x_audio_metadata = handle_json_post(np.zeros(0), query_string, {})
return data.tobytes(), x_audio_metadata

def handle_post(userid, n_samples, in_data_raw,
query_string, print_status=True, client_address=None) -> Tuple[Any, str]:
query_string, client_address=None) -> Tuple[Any, str]:
if not userid.isdigit():
raise ValueError("UserID must be numeric; got: %r"%userid)
try:
Expand Down Expand Up @@ -141,7 +141,7 @@ def handle_post(userid, n_samples, in_data_raw,
query_string += '&rms_volume=%s'%rms_volume

data, x_audio_metadata = handle_json_post(
in_data, query_string, json_kvs, print_status,
in_data, query_string, json_kvs,
client_address=client_address)

# Divide data into user_summary and raw audio data
Expand Down Expand Up @@ -169,11 +169,9 @@ def handle_post(userid, n_samples, in_data_raw,

return data.tobytes(), x_audio_metadata

def handle_json_post(in_data, query_string, json_kvs, print_status,
client_address=None):
def handle_json_post(in_data, query_string, json_kvs, client_address=None):
json_kvs.update({
"query_string": query_string,
"print_status": print_status,
"client_address": client_address,
})
out_json_raw, out_data = backend.handle_post(json.dumps(json_kvs), in_data)
Expand Down
6 changes: 2 additions & 4 deletions unit-stress.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,13 @@ def fake_outer_request():
PACKET_SAMPLES,
data,
[],
query_string(),
print_status=False)
query_string())

def fake_inner_request():
server.handle_post(
data,
[],
query_string(),
print_status=False)
query_string())

def stress():
for i in range(3):
Expand Down

0 comments on commit b218a77

Please sign in to comment.