# Querying port while in a while loop.

**URL:** <https://forum.kx.com/t/querying-port-while-in-a-while-loop/11658>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [December 15, 2017, 6:50am UTC](https://forum.kx.com/t/querying-port-while-in-a-while-loop/11658 "2017-12-15T06:50:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arun1](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@Arun1](https://forum.kx.com/u/Arun1)\
**Post date:** [December 15, 2017, 6:50am UTC](https://forum.kx.com/t/querying-port-while-in-a-while-loop/11658/1 "2017-12-15T06:50:00Z")

</div>

Hi everyone,

I have q process that needs to go into a while loop that can take a long time to complete. However when this happens , querying the process port does not work. Is there any way to overcome this problem ?

Thanks

---

<div class="post-metadata">

**Author:** ![Emil](https://avatars.discourse-cdn.com/v4/letter/e/f4b2a3/32.png) [@Emil](https://forum.kx.com/u/Emil)\
**Post date:** [December 15, 2017, 12:31pm UTC](https://forum.kx.com/t/querying-port-while-in-a-while-loop/11658/2 "2017-12-15T12:31:00Z")

</div>

It is not possible to query the server while the master thread is computing. However, you may be able to run multiple q processes in a load balancing setup to achieve what you want to do: [http://code.kx.com/q/cookbook/load-balancing/](http://code.kx.com/q/cookbook/load-balancing/)

---

<div class="post-metadata">

**Author:** ![Flying1](https://avatars.discourse-cdn.com/v4/letter/f/f4b2a3/32.png) [@Flying1](https://forum.kx.com/u/Flying1)\
**Post date:** [December 15, 2017, 3:08pm UTC](https://forum.kx.com/t/querying-port-while-in-a-while-loop/11658/3 "2017-12-15T15:08:00Z")

</div>

Given that q is a single-threaded process, it’s not possible when the master thread is busy.

One possible alternative is to break the computationally intensive process into multiple smaller parts, and schedule each part to be executed sequentially on a timer. With this approach, you are effectively giving client processes intermittent opportunities to interact with the server.
